Documentation
¶
Index ¶
- Constants
- func InitVips()
- func ParseColor(s string) (color.Color, error)
- func ReadIPTCHeadline(path string) string
- func ShutdownVips()
- type Color
- type Filter
- type VipsImage
- func (v *VipsImage) AddFrame(top, right, bottom, left int, c color.Color) error
- func (v *VipsImage) AddLabel(text, font string, fontSize int, offsetX, imageBottomY, paddingY int) error
- func (v *VipsImage) AddUniformFrame(width int, c color.Color) error
- func (v *VipsImage) Close()
- func (v *VipsImage) Grayscale() (pix []byte, width, height int, err error)
- func (v *VipsImage) Height() int
- func (v *VipsImage) ResizeToFit(maxWidth, maxHeight int, filter Filter) error
- func (v *VipsImage) Save(path string, quality int) error
- func (v *VipsImage) SaveJPEG(path string, quality int) error
- func (v *VipsImage) Width() int
Constants ¶
const KernelMKS2021 vips.Kernel = 7
KernelMKS2021 is Magic Kernel Sharp 2021, added in libvips 8.15 govips doesn't export this yet, so we define it here. Value 7 corresponds to VIPS_KERNEL_MKS2021 in libvips.
Variables ¶
This section is empty.
Functions ¶
func InitVips ¶
func InitVips()
InitVips initializes the vips library. Call once at startup. Log level defaults to error. Set ANSEL_LOG_LEVEL env var to change: error, warning, info, debug
func ParseColor ¶
ParseColor parses a color string into a color.Color. Supports hex colors (#RGB, #RRGGBB, #RRGGBBAA) and named colors.
func ReadIPTCHeadline ¶
ReadIPTCHeadline extracts the IPTC headline from an image file. It first checks for a DXO PhotoLab sidecar file (.dop), then falls back to embedded IPTC metadata in the image. Returns empty string if no headline is found or on error.
Types ¶
type Filter ¶
type Filter int
Filter represents a resampling filter type.
const ( // Lanczos is a high-quality filter, good for downscaling. Lanczos Filter = iota // CatmullRom is a cubic filter with good sharpness. CatmullRom // Bilinear is a fast, simple filter. Bilinear // MagicKernelSharp2021 is the gold-standard resizing filter used by Facebook/Instagram. // It combines the Magic Kernel with optimized sharpening for superior results. MagicKernelSharp2021 )
func ParseFilter ¶
ParseFilter converts a string to a Filter type.
type VipsImage ¶
type VipsImage struct {
// contains filtered or unexported fields
}
VipsImage wraps a govips image reference.
func LoadVipsBuffer ¶
LoadVipsBuffer loads an image from memory. Embedded RAW previews arrive as bytes on a pipe, never as a file on disk.
func (*VipsImage) AddLabel ¶
func (v *VipsImage) AddLabel(text, font string, fontSize int, offsetX, imageBottomY, paddingY int) error
AddLabel renders a text label on the image with a white background. Font should be in Pango format, e.g. "sans 24" or "Arial Bold 18". fontSize is the point size used in the font string (needed for positioning). offsetX is the X position where the image starts (left edge alignment). imageBottomY is the Y position where the image ends (bottom edge). paddingY is the vertical padding between image bottom and label top.
func (*VipsImage) AddUniformFrame ¶
AddUniformFrame adds a uniform frame on all sides.
func (*VipsImage) Grayscale ¶
Grayscale returns one luminance byte per pixel.
The pixels are taken straight from vips memory rather than round-tripped through JPEG. That matters for analysis: JPEG re-encoding introduces high-frequency ringing, which is precisely the signal a sharpness measurement is looking for, so a re-encoded frame would score as sharper than it is.
func (*VipsImage) ResizeToFit ¶
ResizeToFit resizes to fit within the given dimensions, maintaining aspect ratio.