Documentation
¶
Index ¶
- Variables
- func ExtractImageArea(imageRef *ImageRef, left, top, width, height int) error
- func GravityImage(imageRef *ImageRef, direction CompassDirection, width, height int, ...) error
- func HasAlphaChannel(imageRef *ImageRef) bool
- func ResizeImage(imageRef *ImageRef, scale, vscale float64, kernel Kernel) error
- func SaveBuffer(imageRef *ImageRef, params *ExportParams) ([]byte, error)
- func Startup(config *StartupConfig)
- type CompassDirection
- type ExportParams
- type Extend
- type ImageRef
- type ImageType
- type Kernel
- type StartupConfig
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnsupportedImageFormat when image type is unsupported ErrUnsupportedImageFormat = errors.New("Unsupported image format") )
Functions ¶
func ExtractImageArea ¶
ExtractImageArea crops image to specified size
func GravityImage ¶
func GravityImage(imageRef *ImageRef, direction CompassDirection, width, height int, extend Extend, red, green, blue float64) error
GravityImage changes canvas size with specified direction and canvas fill logic
func HasAlphaChannel ¶
HasAlphaChannel checks is image have alpha channel or not
func ResizeImage ¶
ResizeImage resizes input image with one of the specified interpolation algorithms
func SaveBuffer ¶
func SaveBuffer(imageRef *ImageRef, params *ExportParams) ([]byte, error)
SaveBuffer saves vips image to bytes
func Startup ¶
func Startup(config *StartupConfig)
Startup sets up the vips support and ensures the versions are correct. Pass in nil for default configuration.
Types ¶
type CompassDirection ¶
type CompassDirection int
CompassDirection represents VipsCompassDirection type
const ( CompassDirectionCentre CompassDirection = C.VIPS_COMPASS_DIRECTION_CENTRE CompassDirectionNorth CompassDirection = C.VIPS_COMPASS_DIRECTION_NORTH CompassDirectionEast CompassDirection = C.VIPS_COMPASS_DIRECTION_EAST CompassDirectionSouth CompassDirection = C.VIPS_COMPASS_DIRECTION_SOUTH CompassDirectionWest CompassDirection = C.VIPS_COMPASS_DIRECTION_WEST CompassDirectionNorthEast CompassDirection = C.VIPS_COMPASS_DIRECTION_NORTH_EAST CompassDirectionSouthEast CompassDirection = C.VIPS_COMPASS_DIRECTION_SOUTH_EAST CompassDirectionSouthWest CompassDirection = C.VIPS_COMPASS_DIRECTION_SOUTH_WEST CompassDirectionNorthWest CompassDirection = C.VIPS_COMPASS_DIRECTION_NORTH_WEST )
CompassDirection enum
type ExportParams ¶
type ExportParams struct { Format ImageType Quality int Compression int Interlaced bool Lossless bool StripMetadata bool }
ExportParams are options when exporting an image to file or buffer
type Extend ¶
type Extend int
Extend represents VipsExtend type
const ( ExtendBlack Extend = C.VIPS_EXTEND_BLACK // Black pixels ExtendCopy Extend = C.VIPS_EXTEND_COPY // Copies the image edges ExtendRepeat Extend = C.VIPS_EXTEND_REPEAT // Repeats the whole image ExtendMirror Extend = C.VIPS_EXTEND_MIRROR // Mirrors the whole image ExtendWhite Extend = C.VIPS_EXTEND_WHITE // White pixels ExtendBackground Extend = C.VIPS_EXTEND_BACKGROUND // Selects color from background property ExtendLast Extend = C.VIPS_EXTEND_LAST // Extends with last pixel )
Extend enum
type ImageRef ¶
type ImageRef struct { Image *C.VipsImage Format ImageType // NOTE(d): We keep a reference to this so that the input buffer is // never garbage collected during processing. Some image loaders use random // access transcoding and therefore need the original buffer to be in memory. Buf []byte }
ImageRef contains a libvips image and manages its lifecycle. You should close an image when done or it will leak until the next GC
type Kernel ¶
type Kernel int
Kernel represents VipsKernel type
const ( KernelNearest Kernel = C.VIPS_KERNEL_NEAREST KernelLinear Kernel = C.VIPS_KERNEL_LINEAR KernelCubic Kernel = C.VIPS_KERNEL_CUBIC KernelLanczos2 Kernel = C.VIPS_KERNEL_LANCZOS2 KernelLanczos3 Kernel = C.VIPS_KERNEL_LANCZOS3 )
Kernel enum