Versions in this module Expand all Collapse all v0 v0.1.0 May 3, 2026 Changes in this version + var ErrFileTooLarge = errors.New("file size exceeds maximum allowed size") + var ErrPreserveMetadataNotSupported = errors.New("preserve metadata is not yet supported") + type BatchConvertItem struct + InputPath string + Options ConvertOptions + OutputPath string + func ScanDirectoryForConvert(inputDir, outputDir string, targetFormat ImageFormat, ...) ([]BatchConvertItem, error) + type BatchConvertResult struct + Error error + Item BatchConvertItem + Result *Result + func (br *BatchConvertResult) IsSuccess() bool + type BatchItem struct + InputPath string + Options CompressOptions + OutputPath string + func ScanDirectory(inputDir, outputDir string, opts ...ScanDirectoryOption) ([]BatchItem, error) + type BatchProcessor interface + ProcessBatch func(ctx context.Context, items []BatchItem) ([]BatchResult, error) + type BatchProcessorOption func(*DefaultBatchProcessor) + func WithMaxWorkers(n int) BatchProcessorOption + func WithProgressCallback(cb func(Progress)) BatchProcessorOption + type BatchResult struct + Error error + Item BatchItem + Result *Result + func (br *BatchResult) IsSuccess() bool + type CompressOptions struct + Level CompressionLevel + MaxFileSize int64 + PreserveMetadata bool + Quality int + func DefaultCompressOptions() CompressOptions + func (o CompressOptions) Validate() error + type CompressionLevel int + const CompressionHigh + const CompressionLow + const CompressionMedium + func (c CompressionLevel) IsValid() bool + func (c CompressionLevel) String() string + func (c CompressionLevel) ToJPEGQuality() int + func (c CompressionLevel) ToPNGCompressionLevel() png.CompressionLevel + func (c CompressionLevel) ToWebPQuality() float32 + type ConvertOptions struct + Format ImageFormat + func DefaultConvertOptions(format ImageFormat) ConvertOptions + type DefaultBatchProcessor struct + func NewDefaultBatchProcessor(opts ...BatchProcessorOption) *DefaultBatchProcessor + func (bp *DefaultBatchProcessor) ProcessBatch(ctx context.Context, items []BatchItem) ([]BatchResult, error) + func (bp *DefaultBatchProcessor) ProcessBatchConvert(ctx context.Context, items []BatchConvertItem) ([]BatchConvertResult, error) + type ImageFormat int + const FormatJPEG + const FormatPNG + const FormatWEBP + func (f ImageFormat) Extension() string + func (f ImageFormat) IsValid() bool + func (f ImageFormat) MIMEType() string + func (f ImageFormat) String() string + type JPEGProcessor struct + func NewJPEGProcessor() *JPEGProcessor + func (p *JPEGProcessor) Compress(ctx context.Context, r io.Reader, w io.Writer, opts CompressOptions) (*Result, error) + func (p *JPEGProcessor) Convert(ctx context.Context, r io.Reader, w io.Writer, opts ConvertOptions) (*Result, error) + func (p *JPEGProcessor) SupportedFormats() []ImageFormat + type PNGProcessor struct + func NewPNGProcessor() *PNGProcessor + func (p *PNGProcessor) Compress(ctx context.Context, r io.Reader, w io.Writer, opts CompressOptions) (*Result, error) + func (p *PNGProcessor) Convert(ctx context.Context, r io.Reader, w io.Writer, opts ConvertOptions) (*Result, error) + func (p *PNGProcessor) SupportedFormats() []ImageFormat + type Processor interface + Compress func(ctx context.Context, r io.Reader, w io.Writer, opts CompressOptions) (*Result, error) + Convert func(ctx context.Context, r io.Reader, w io.Writer, opts ConvertOptions) (*Result, error) + SupportedFormats func() []ImageFormat + type Progress struct + Completed int + Current string + Failed int + Total int + type Result struct + CompressedSize int64 + Format ImageFormat + OriginalSize int64 + func (r *Result) CompressionRatio() float64 + func (r *Result) SavedBytes() int64 + func (r *Result) SavedPercentage() float64 + type ScanDirectoryForConvertOption func(*scanConvertConfig) + func WithConvertOptions(opts ConvertOptions) ScanDirectoryForConvertOption + type ScanDirectoryOption func(*scanConfig) + func WithCompressOptions(opts CompressOptions) ScanDirectoryOption + type WEBPProcessor struct + func NewWEBPProcessor() *WEBPProcessor + func (p *WEBPProcessor) Compress(ctx context.Context, r io.Reader, w io.Writer, opts CompressOptions) (*Result, error) + func (p *WEBPProcessor) Convert(ctx context.Context, r io.Reader, w io.Writer, opts ConvertOptions) (*Result, error) + func (p *WEBPProcessor) SupportedFormats() []ImageFormat