optimize

package
v0.0.0-...-57218f6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Optimize

func Optimize(w io.Writer, img image.Image, format string, opts OptimizeOptions) error

Optimize writes the image to the writer with optimization options

Types

type OptimizeOptions

type OptimizeOptions struct {
	Quality       int  // 1-100 for JPEG/WebP
	Progressive   bool // For JPEG
	Compression   int  // 0-9 for PNG
	StripMetadata bool // Remove EXIF and other metadata
	AutoQuality   bool // Automatically determine quality based on image content
}

func DefaultOptions

func DefaultOptions(format string) OptimizeOptions

DefaultOptions returns recommended optimization options per format

func GetOptionsForQuality

func GetOptionsForQuality(format string, level QualityLevel) OptimizeOptions

GetOptionsForQuality returns optimization options for a specific quality level

type QualityLevel

type QualityLevel string
const (
	QualityLow      QualityLevel = "low"      // 60% quality
	QualityMedium   QualityLevel = "medium"   // 75% quality
	QualityHigh     QualityLevel = "high"     // 90% quality
	QualityLossless QualityLevel = "lossless" // 100% quality
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL