Documentation
¶
Index ¶
- Variables
- func Convert(src image.Image, opts ConvertOptions) (image.Image, error)
- func ConvertFile(inputPath string, opts ConvertOptions) (image.Image, error)
- func Encode(w io.Writer, img image.Image, opts SaveOptions) error
- func GenerateOutputPath(inputPath string, format Format, suffix string) string
- func IsSupported(format Format) bool
- func Load(path string) (image.Image, error)
- func LoadFromReader(r io.Reader) (image.Image, error)
- func Resize(src image.Image, opts ResizeOptions) (image.Image, error)
- func ResizeFile(inputPath string, opts ResizeOptions) (image.Image, error)
- func Save(img image.Image, path string, opts ...SaveOptions) error
- type ConvertOptions
- type EXIFData
- type Format
- type Metadata
- type ResizeOptions
- type SaveOptions
Constants ¶
This section is empty.
Variables ¶
var SupportedFormats = []Format{ FormatPNG, FormatJPEG, FormatJPG, FormatGIF, FormatBMP, FormatTIFF, FormatWEBP, }
SupportedFormats lists all supported image formats
Functions ¶
func Convert ¶
Convert converts an image to a different format The actual format conversion happens during Save()
func ConvertFile ¶
func ConvertFile(inputPath string, opts ConvertOptions) (image.Image, error)
ConvertFile loads an image and prepares it for conversion
func GenerateOutputPath ¶
GenerateOutputPath creates an output path based on input and format
func LoadFromReader ¶
LoadFromReader reads an image from an io.Reader
func ResizeFile ¶
func ResizeFile(inputPath string, opts ResizeOptions) (image.Image, error)
ResizeFile loads, resizes, and returns the processed image
Types ¶
type ConvertOptions ¶
type ConvertOptions struct {
Format Format // Target format
Quality int // Output quality (1-100, for JPEG)
}
ConvertOptions configures image conversion
type EXIFData ¶
type EXIFData struct {
Make string `json:"make,omitempty"`
Model string `json:"model,omitempty"`
DateTime *time.Time `json:"datetime,omitempty"`
Orientation int `json:"orientation,omitempty"`
ExposureTime string `json:"exposure_time,omitempty"`
FNumber string `json:"f_number,omitempty"`
ISOSpeed int `json:"iso_speed,omitempty"`
FocalLength string `json:"focal_length,omitempty"`
GPSLatitude float64 `json:"gps_latitude,omitempty"`
GPSLongitude float64 `json:"gps_longitude,omitempty"`
}
EXIFData contains EXIF metadata from photos
type Format ¶
type Format string
Format represents a supported image format
func FormatFromExtension ¶
FormatFromExtension extracts format from filename
func NormalizeFormat ¶
NormalizeFormat normalizes format strings (e.g., "jpg" -> "jpeg")
type Metadata ¶
type Metadata struct {
Width int `json:"width"`
Height int `json:"height"`
Format string `json:"format"`
SizeBytes int64 `json:"size_bytes"`
ColorMode string `json:"color_mode,omitempty"`
HasAlpha bool `json:"has_alpha"`
EXIF *EXIFData `json:"exif,omitempty"`
}
Metadata contains image information
type ResizeOptions ¶
type ResizeOptions struct {
Width int // Target width in pixels (0 to auto-calculate from aspect ratio)
Height int // Target height in pixels (0 to auto-calculate from aspect ratio)
Fit string // Fit mode: "contain", "cover", "fill"
Quality int // Output quality (1-100, for JPEG/WebP)
}
ResizeOptions configures image resizing behavior
type SaveOptions ¶
type SaveOptions struct {
Format Format // Target format (defaults to extension-based detection)
Quality int // Quality for lossy formats (1-100, default 85)
}
SaveOptions configures image saving