Documentation
¶
Overview ¶
Package vips provides minimal purego bindings for libvips image processing. This package is NOT safe for concurrent use of the same Image instance. Callers must synchronize access if sharing Images across goroutines.
Index ¶
- func ClearCache()
- func Shutdown()
- func Startup(config *Config) error
- func Version() string
- type Config
- type Image
- func (img *Image) Close()
- func (img *Image) ExportWebp(params *WebpExportParams) ([]byte, *ImageMetadata, error)
- func (img *Image) ExtractArea(left, top, width, height int) error
- func (img *Image) Height() int
- func (img *Image) IsValid() bool
- func (img *Image) Resize(scale float64, kernel Kernel) error
- func (img *Image) Sharpen(sigma, x1, m2 float64) error
- func (img *Image) Width() int
- type ImageMetadata
- type Kernel
- type WebpExportParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearCache ¶
func ClearCache()
ClearCache clears the libvips operation cache. Sets cache to 0, then restores to configured defaults. Does nothing if vips is not initialized.
func Shutdown ¶
func Shutdown()
Shutdown releases all libvips resources. Should be called before program exit.
Types ¶
type Config ¶
type Config struct {
MaxCacheSize int // Max operations to cache (0 = disable cache)
MaxCacheMem int // Max memory for cache in bytes (0 = disable cache memory limit)
}
Config holds initialization options for libvips.
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image represents a libvips image. Image is NOT safe for concurrent use from multiple goroutines. The caller must synchronize access if sharing an Image across goroutines.
func NewImageFromBuffer ¶
NewImageFromBuffer loads an image from a byte buffer. Supports JPEG, PNG, WebP, GIF, and other formats that libvips can decode.
func (*Image) Close ¶
func (img *Image) Close()
Close releases the image resources. The image must not be used after calling Close. Close is idempotent and safe to call multiple times.
func (*Image) ExportWebp ¶
func (img *Image) ExportWebp(params *WebpExportParams) ([]byte, *ImageMetadata, error)
ExportWebp exports the image as WebP format. Returns the encoded bytes and the WebP metadata. The second return value is for API compatibility (always nil).
func (*Image) ExtractArea ¶
ExtractArea extracts a rectangular region from the image. The operation modifies the image in place.
func (*Image) Resize ¶
Resize scales the image by the given factor using the specified kernel. A scale of 0.5 halves the size, 2.0 doubles it. The operation modifies the image in place.
type ImageMetadata ¶
type ImageMetadata struct{}
ImageMetadata is a placeholder for API compatibility. Currently not implemented.
type Kernel ¶
type Kernel int
Kernel defines the resampling kernel for resize operations.
const ( KernelNearest Kernel = 0 // Nearest neighbor - fastest, pixelated KernelLinear Kernel = 1 // Bilinear interpolation KernelCubic Kernel = 2 // Bicubic interpolation KernelMitchell Kernel = 3 // Mitchell-Netravali - good for photos KernelLanczos2 Kernel = 4 // Lanczos with a=2 KernelLanczos3 Kernel = 5 // Lanczos with a=3 - sharpest, recommended )
type WebpExportParams ¶
type WebpExportParams struct {
Quality int // Quality factor (0-100, default 75). Values outside range are clamped.
StripMetadata bool // Strip all metadata
}
WebpExportParams configures WebP encoding options.
func NewWebpExportParams ¶
func NewWebpExportParams() *WebpExportParams
NewWebpExportParams returns WebpExportParams with default values.