Versions in this module Expand all Collapse all v1 v1.0.0 Jun 30, 2026 Changes in this version + var ErrInvalidICCProfile = errors.New("invalid ICC profile data") + var ErrInvalidJPEG = errors.New("invalid JPEG data") + var ErrNoEXIF = errors.New("no EXIF data found in source image") + var ErrNoICC = errors.New("no ICC profile found in source image") + func EmbedJPEGIdentical(img image.Image, quality int, password string, message []byte) ([]byte, error) + func EmbedJPEGWithOptions(img image.Image, quality int, password string, message []byte, opts ...Option) ([]byte, error) + func EncodeBatch(items []BatchItem, workers int) []error + func GetJamesStyleHuffmanSpecs() []jpeg.HuffmanSpec + func ParseEXIF(r io.Reader) ([]byte, error) + func ParseEXIFBytes(data []byte) ([]byte, error) + func ParseICCProfile(r io.Reader) ([]byte, error) + func ParseICCProfileBytes(data []byte) ([]byte, error) + func WeeksEncodeToBytes(img image.Image, quality int) ([]byte, error) + func WeeksEncodeToBytesStandard(img image.Image, quality int) ([]byte, error) + func WriteBMP24(w io.Writer, img image.Image) error + type BatchItem struct + Image image.Image + Options []Option + Quality int + Writer io.Writer + type BitWriter interface + Flush func() error + WriteBits func(bits uint32, nBits int) error + type BitWriterAdapter struct + func NewBitWriterAdapter(bw *jpeg.EncoderBitWriter) *BitWriterAdapter + func (a *BitWriterAdapter) Flush() error + func (a *BitWriterAdapter) WriteBits(bits uint32, nBits int) error + type BlockEncoder interface + EncodeBlock func(block *[64]int, prevDC int, isLuminance bool) (newDC int, err error) + Flush func() error + type BlockExtractor interface + ExtractBlock func(img image.Image, component, x, y int) [64]float64 + type BlockTapFunc func(blockIndex int, isLuminance bool, block *[64]int) + type CustomHuffmanTable struct + func NewCustomHuffmanTable(tableClass, tableNum int, bits [16]byte, values []byte) (*CustomHuffmanTable, error) + func (t *CustomHuffmanTable) Encode(symbol byte) (code uint16, size uint8) + func (t *CustomHuffmanTable) GetBits() [16]byte + func (t *CustomHuffmanTable) GetEncoderTable() *jpeg.HuffmanEncoderTable + func (t *CustomHuffmanTable) GetTableClass() int + func (t *CustomHuffmanTable) GetTableNum() int + func (t *CustomHuffmanTable) GetValues() []byte + type DCT interface + Forward func(block *[64]float64) + type DCTAdapter struct + func NewDCTAdapter(dct jpeg.DCTTransformer) *DCTAdapter + func (a *DCTAdapter) Forward(block *[64]float64) + type HuffmanBlockEncoder struct + func NewHuffmanBlockEncoder(bw BitWriter, dcLum, dcChrom, acLum, acChrom HuffmanTable) *HuffmanBlockEncoder + func (e *HuffmanBlockEncoder) EncodeBlock(block *[64]int, prevDC int, isLuminance bool) (newDC int, err error) + func (e *HuffmanBlockEncoder) Flush() error + type HuffmanTable interface + Encode func(symbol byte) (code uint16, size uint8) + type HuffmanTableAdapter struct + func NewHuffmanTableAdapter(table *jpeg.HuffmanEncoderTable) *HuffmanTableAdapter + func (a *HuffmanTableAdapter) Encode(symbol byte) (code uint16, size uint8) + type IJGQuantizer struct + func NewIJGQuantizer(quality int) (*IJGQuantizer, error) + func (q *IJGQuantizer) GetQuantTable(isLuminance bool) [64]int + func (q *IJGQuantizer) QuantizeBlock(block *[64]float64, isLuminance bool) [64]int + type JamesBitWriter struct + func NewJamesBitWriter(w io.Writer) *JamesBitWriter + func (bw *JamesBitWriter) Flush() error + func (bw *JamesBitWriter) WriteBits(bits uint32, nBits int) error + type JamesBlockExtractor struct + Cb [][]float32 + Cr [][]float32 + Y [][]float32 + func NewJamesBlockExtractor(img image.Image, subsampling jpeg.ChromaSubsamplingMode) *JamesBlockExtractor + func (e *JamesBlockExtractor) ExtractBlock(img image.Image, component, x, y int) [64]float64 + type JamesQuantizer struct + func NewJamesQuantizer(quality int) (*JamesQuantizer, error) + func (jq *JamesQuantizer) ForwardDCTAndQuantize(input *[64]float64, isLuminance bool) [64]int + func (jq *JamesQuantizer) GetQuantTable(isLuminance bool) [64]int + func (jq *JamesQuantizer) QuantizeBlock(block *[64]float64, isLuminance bool) [64]int + type MockBitWriter struct + Flushed bool + WriteErr error + WrittenBits []struct{ ... } + func (m *MockBitWriter) Flush() error + func (m *MockBitWriter) WriteBits(bits uint32, nBits int) error + type MockBlockEncoder struct + EncodeCalls int + EncodeErr error + EncodedBlocks []struct{ ... } + FlushErr error + Flushed bool + func (m *MockBlockEncoder) EncodeBlock(block *[64]int, prevDC int, isLuminance bool) (newDC int, err error) + func (m *MockBlockEncoder) Flush() error + type MockBlockExtractor struct + ExtractCalls int + ExtractedPositions []struct{ ... } + FixedBlock [64]float64 + func (m *MockBlockExtractor) ExtractBlock(img image.Image, component, x, y int) [64]float64 + type MockDCT struct + ForwardCalls int + TransformFunc func(block *[64]float64) + func (m *MockDCT) Forward(block *[64]float64) + type MockHuffmanTable struct + Codes map[byte]struct{ ... } + func (m *MockHuffmanTable) Encode(symbol byte) (code uint16, size uint8) + type MockQuantizer struct + ChromTable [64]int + LumTable [64]int + QuantizeCalls int + func (m *MockQuantizer) GetQuantTable(isLuminance bool) [64]int + func (m *MockQuantizer) QuantizeBlock(block *[64]float64, isLuminance bool) [64]int + type Option func(*WeeksEncoder) + func WithBlockEncoder(be BlockEncoder) Option + func WithBlockExtractor(bx BlockExtractor) Option + func WithBlockTap(tap BlockTapFunc) Option + func WithComment(comment string) Option + func WithDCT(dct DCT) Option + func WithEXIF(exifData []byte) Option + func WithICCProfile(iccProfile []byte) Option + func WithMaxWorkers(n int) Option + func WithParallelEncoding(enabled bool) Option + func WithPixelKnotHeaders() Option + func WithQuantizer(q Quantizer) Option + func WithSourceImage(r io.Reader) Option + func WithSourceImageBytes(data []byte) Option + func WithStandardMode() Option + func WithSubsampling(mode jpeg.ChromaSubsamplingMode) Option + func WithoutAPP0() Option + func WithoutComment() Option + type Quantizer interface + GetQuantTable func(isLuminance bool) [64]int + QuantizeBlock func(block *[64]float64, isLuminance bool) [64]int + type TapBlockEncoder struct + Inner BlockEncoder + Tap BlockTapFunc + func NewTapBlockEncoder(inner BlockEncoder, tap BlockTapFunc) *TapBlockEncoder + func (t *TapBlockEncoder) EncodeBlock(block *[64]int, prevDC int, isLuminance bool) (int, error) + func (t *TapBlockEncoder) Flush() error + func (t *TapBlockEncoder) Reset() + type WeeksEncoder struct + func NewWeeksEncoder(w io.Writer, quality int) (*WeeksEncoder, error) + func NewWeeksEncoderWithOptions(w io.Writer, quality int, opts ...Option) (*WeeksEncoder, error) + func (e *WeeksEncoder) Encode(img image.Image) error + func (e *WeeksEncoder) GetHuffmanTableError() error + func (e *WeeksEncoder) HasCustomHuffmanTable(tableClass, tableNum int) bool + func (e *WeeksEncoder) SetComment(comment string) *WeeksEncoder + func (e *WeeksEncoder) SetHuffmanTable(tableClass, tableNum int, bits [16]byte, values []byte) *WeeksEncoder + func (e *WeeksEncoder) SetQuantizationTable(tableNum int, table [64]int) *WeeksEncoder + func (e *WeeksEncoder) SetSubsampling(mode jpeg.ChromaSubsamplingMode) *WeeksEncoder + type YCbCrBlockExtractor struct + func NewYCbCrBlockExtractor(subsampling jpeg.ChromaSubsamplingMode) *YCbCrBlockExtractor + func (e *YCbCrBlockExtractor) ExtractBlock(img image.Image, component, x, y int) [64]float64