Documentation ¶
Overview ¶
Package vips provides go bindings for libvips, a fast image processing library.
Index ¶
- Constants
- Variables
- func ClearCache()
- func IsTypeSupported(imageType ImageType) bool
- func LoggingSettings(handler LoggingHandlerFunction, verbosity LogLevel)
- func PrintCache()
- func PrintObjectReport(label string)
- func ReadRuntimeStats(stats *RuntimeStats)
- func ReadVipsMemStats(stats *MemoryStats)
- func Shutdown()
- func ShutdownThread()
- func Startup(config *Config)
- type Align
- type Angle
- type Angle45
- type BandFormat
- type BlendMode
- type Coding
- type Color
- type ColorRGBA
- type Config
- type Direction
- type ExportParams
- type ExtendStrategy
- type HeifExportParams
- type ImageComposite
- type ImageMetadata
- type ImageRef
- func Black(width, height int) (*ImageRef, error)
- func Identity(ushort bool) (*ImageRef, error)
- func NewImageFromBuffer(buf []byte) (*ImageRef, error)
- func NewImageFromFile(file string) (*ImageRef, error)
- func NewImageFromReader(r io.Reader) (*ImageRef, error)
- func XYZ(width, height int) (*ImageRef, error)
- func (r *ImageRef) Add(addend *ImageRef) error
- func (r *ImageRef) AddAlpha() error
- func (r *ImageRef) AutoRotate() error
- func (r *ImageRef) Average() (float64, error)
- func (r *ImageRef) BandFormat() BandFormat
- func (r *ImageRef) BandJoin(images ...*ImageRef) error
- func (r *ImageRef) BandJoinConst(constants []float64) error
- func (r *ImageRef) Bands() int
- func (r *ImageRef) Cast(format BandFormat) error
- func (r *ImageRef) Close()
- func (r *ImageRef) Coding() Coding
- func (r *ImageRef) ColorSpace() Interpretation
- func (r *ImageRef) Composite(overlay *ImageRef, mode BlendMode, x, y int) error
- func (r *ImageRef) CompositeMulti(ins []*ImageComposite) error
- func (r *ImageRef) Copy() (*ImageRef, error)
- func (r *ImageRef) CopyMemory() (*ImageRef, error)
- func (r *ImageRef) Divide(denominator *ImageRef) error
- func (r *ImageRef) DrawRect(ink ColorRGBA, left int, top int, width int, height int, fill bool) error
- func (r *ImageRef) Embed(left, top, width, height int, extend ExtendStrategy) error
- func (r *ImageRef) Export(params *ExportParams) ([]byte, *ImageMetadata, error)
- func (r *ImageRef) ExportHeif(params *HeifExportParams) ([]byte, *ImageMetadata, error)
- func (r *ImageRef) ExportJpeg(params *JpegExportParams) ([]byte, *ImageMetadata, error)
- func (r *ImageRef) ExportNative() ([]byte, *ImageMetadata, error)
- func (r *ImageRef) ExportPng(params *PngExportParams) ([]byte, *ImageMetadata, error)
- func (r *ImageRef) ExportTiff(params *TiffExportParams) ([]byte, *ImageMetadata, error)
- func (r *ImageRef) ExportWebp(params *WebpExportParams) ([]byte, *ImageMetadata, error)
- func (r *ImageRef) ExtractArea(left, top, width, height int) error
- func (r *ImageRef) ExtractBand(band int, num int) error
- func (r *ImageRef) Flatten(backgroundColor *Color) error
- func (r *ImageRef) Flip(direction Direction) error
- func (r *ImageRef) Format() ImageType
- func (r *ImageRef) GaussianBlur(sigma float64, precision Precision) error
- func (r *ImageRef) GetOrientation() int
- func (r *ImageRef) HasAlpha() bool
- func (r *ImageRef) HasICCProfile() bool
- func (r *ImageRef) HasIPTC() bool
- func (r *ImageRef) HasProfile() bool
- func (r *ImageRef) Height() int
- func (r *ImageRef) Interpretation() Interpretation
- func (r *ImageRef) Invert() error
- func (r *ImageRef) IsColorSpaceSupported() bool
- func (r *ImageRef) Label(labelParams *LabelParams) error
- func (r *ImageRef) Linear(a, b []float64) error
- func (r *ImageRef) Linear1(a, b float64) error
- func (r *ImageRef) Mapim(index *ImageRef) error
- func (r *ImageRef) Maplut(lut *ImageRef) error
- func (r *ImageRef) Metadata() *ImageMetadata
- func (r *ImageRef) Modulate(brightness, saturation, hue float64) error
- func (r *ImageRef) ModulateHSV(brightness, saturation float64, hue int) error
- func (r *ImageRef) Multiply(multiplier *ImageRef) error
- func (r *ImageRef) OffsetX() int
- func (r *ImageRef) OffsetY() int
- func (r *ImageRef) OptimizeICCProfile() error
- func (r *ImageRef) PremultiplyAlpha() error
- func (r *ImageRef) RemoveICCProfile() error
- func (r *ImageRef) RemoveMetadata() error
- func (r *ImageRef) RemoveOrientation() error
- func (r *ImageRef) ResX() float64
- func (r *ImageRef) ResY() float64
- func (r *ImageRef) Resize(scale float64, kernel Kernel) error
- func (r *ImageRef) ResizeWithVScale(hScale, vScale float64, kernel Kernel) error
- func (r *ImageRef) Rotate(angle Angle) error
- func (r *ImageRef) SetOrientation(orientation int) error
- func (r *ImageRef) Sharpen(sigma float64, x1 float64, m2 float64) error
- func (r *ImageRef) Similarity(scale float64, angle float64, backgroundColor *ColorRGBA, idx float64, ...) error
- func (r *ImageRef) SmartCrop(width int, height int, interesting Interesting) error
- func (r *ImageRef) Thumbnail(width, height int, crop Interesting) error
- func (r *ImageRef) ToBytes() ([]byte, error)
- func (r *ImageRef) ToColorSpace(interpretation Interpretation) error
- func (r *ImageRef) ToImage(params *ExportParams) (image.Image, error)
- func (r *ImageRef) UnpremultiplyAlpha() error
- func (r *ImageRef) Width() int
- func (r *ImageRef) Zoom(xFactor int, yFactor int) error
- type ImageType
- type Intent
- type Interesting
- type Interpretation
- type JpegExportParams
- type JpegSubsampling
- type Kernel
- type LabelParams
- type LogLevel
- type LoggingHandlerFunction
- type MemoryStats
- type PngExportParams
- type PreMultiplicationState
- type Precision
- type RuntimeStats
- type Scalar
- type TiffCompression
- type TiffExportParams
- type TiffPredictor
- type WebpExportParams
Constants ¶
const DefaultFont = "sans 10"
DefaultFont is the default font to be used for label texts created by govips
const MajorVersion = int(C.VIPS_MAJOR_VERSION)
MajorVersion is the libvips major component of the version string (x in x.y.z)
const MicroVersion = int(C.VIPS_MICRO_VERSION)
MicroVersion is the libvips micro component of the version string (z in x.y.z) Also known as patch version
const MinorVersion = int(C.VIPS_MINOR_VERSION)
MinorVersion is the libvips minor component of the version string (y in x.y.z)
const Version = string(C.VIPS_VERSION)
Version is the full libvips version string (x.y.z)
Variables ¶
var ( // ErrUnsupportedImageFormat when image type is unsupported ErrUnsupportedImageFormat = errors.New("unsupported image format") )
var GenericGrayGamma22ICCProfilePath = filepath.Join(temporaryDirectory, "generic_gray_gamma_2_2.icc")
var ImageTypes = map[ImageType]string{ ImageTypeGIF: "gif", ImageTypeJPEG: "jpeg", ImageTypeMagick: "magick", ImageTypePDF: "pdf", ImageTypePNG: "png", ImageTypeSVG: "svg", ImageTypeTIFF: "tiff", ImageTypeWEBP: "webp", ImageTypeHEIF: "heif", ImageTypeBMP: "bmp", }
ImageTypes defines the various image types supported by govips
var SGrayV2MicroICCProfilePath = filepath.Join(temporaryDirectory, "sgray_v2_micro.icc")
var SRGBIEC6196621ICCProfilePath = filepath.Join(temporaryDirectory, "srgb_iec61966_2_1.icc")
var SRGBV2MicroICCProfilePath = filepath.Join(temporaryDirectory, "srgb_v2_micro.icc")
Functions ¶
func ClearCache ¶
func ClearCache()
ClearCache drops the whole operation cache, handy for leak tracking.
func IsTypeSupported ¶
IsTypeSupported checks whether given image type is supported by govips
func LoggingSettings ¶
func LoggingSettings(handler LoggingHandlerFunction, verbosity LogLevel)
LoggingSettings sets the logging handler and logging verbosity for govips. The handler function is the function which will be called for each log message. You can define one yourself to log somewhere else besides the default (stderr). Use nil as handler to use standard logging handler. Verbosity is the minimum logLevel you want to log. Default is logLevelInfo due to backwards compatibility but it's quite verbose for a library. Suggest setting it to at least logLevelWarning. Use logLevelDebug for debugging.
func PrintCache ¶
func PrintCache()
PrintCache prints the whole operation cache to stdout for debugging purposes.
func PrintObjectReport ¶
func PrintObjectReport(label string)
PrintObjectReport outputs all of the current internal objects in libvips
func ReadRuntimeStats ¶
func ReadRuntimeStats(stats *RuntimeStats)
ReadRuntimeStats returns operation counts for govips
func ReadVipsMemStats ¶
func ReadVipsMemStats(stats *MemoryStats)
ReadVipsMemStats returns various memory statistics such as allocated memory and open files.
func ShutdownThread ¶
func ShutdownThread()
ShutdownThread clears the cache for for the given thread. This needs to be called when a thread using vips exits.
Types ¶
type Align ¶
type Align int
Align represents VIPS_ALIGN
const ( AlignLow Align = C.VIPS_ALIGN_LOW AlignCenter Align = C.VIPS_ALIGN_CENTRE AlignHigh Align = C.VIPS_ALIGN_HIGH )
Direction enum
type Angle ¶
type Angle int
Angle represents VIPS_ANGLE type
const ( Angle0 Angle = C.VIPS_ANGLE_D0 Angle90 Angle = C.VIPS_ANGLE_D90 Angle180 Angle = C.VIPS_ANGLE_D180 Angle270 Angle = C.VIPS_ANGLE_D270 )
Angle enum
func GetRotationAngleFromExif ¶
GetRotationAngleFromExif returns the angle which the image is currently rotated in. First returned value is the angle and second is a boolean indicating whether image is flipped. This is based on the EXIF orientation tag standard. If no proper orientation number is provided, the picture will be assumed to be upright.
type Angle45 ¶
type Angle45 int
Angle45 represents VIPS_ANGLE45 type
const ( Angle45_0 Angle45 = C.VIPS_ANGLE45_D0 Angle45_45 Angle45 = C.VIPS_ANGLE45_D45 Angle45_90 Angle45 = C.VIPS_ANGLE45_D90 Angle45_135 Angle45 = C.VIPS_ANGLE45_D135 Angle45_180 Angle45 = C.VIPS_ANGLE45_D180 Angle45_225 Angle45 = C.VIPS_ANGLE45_D225 Angle45_270 Angle45 = C.VIPS_ANGLE45_D270 Angle45_315 Angle45 = C.VIPS_ANGLE45_D315 )
Angle45 enum
type BandFormat ¶
type BandFormat int
BandFormat represents VIPS_FORMAT type
const ( BandFormatNotSet BandFormat = C.VIPS_FORMAT_NOTSET BandFormatUchar BandFormat = C.VIPS_FORMAT_UCHAR BandFormatChar BandFormat = C.VIPS_FORMAT_CHAR BandFormatUshort BandFormat = C.VIPS_FORMAT_USHORT BandFormatShort BandFormat = C.VIPS_FORMAT_SHORT BandFormatUint BandFormat = C.VIPS_FORMAT_UINT BandFormatInt BandFormat = C.VIPS_FORMAT_INT BandFormatFloat BandFormat = C.VIPS_FORMAT_FLOAT BandFormatComplex BandFormat = C.VIPS_FORMAT_COMPLEX BandFormatDouble BandFormat = C.VIPS_FORMAT_DOUBLE BandFormatDpComplex BandFormat = C.VIPS_FORMAT_DPCOMPLEX )
BandFormat enum
type BlendMode ¶
type BlendMode int
BlendMode gives the various Porter-Duff and PDF blend modes. See https://libvips.github.io/libvips/API/current/libvips-conversion.html#VipsBlendMode
const ( BlendModeClear BlendMode = C.VIPS_BLEND_MODE_CLEAR BlendModeSource BlendMode = C.VIPS_BLEND_MODE_SOURCE BlendModeOver BlendMode = C.VIPS_BLEND_MODE_OVER BlendModeIn BlendMode = C.VIPS_BLEND_MODE_IN BlendModeOut BlendMode = C.VIPS_BLEND_MODE_OUT BlendModeAtop BlendMode = C.VIPS_BLEND_MODE_ATOP BlendModeDest BlendMode = C.VIPS_BLEND_MODE_DEST BlendModeDestOver BlendMode = C.VIPS_BLEND_MODE_DEST_OVER BlendModeDestIn BlendMode = C.VIPS_BLEND_MODE_DEST_IN BlendModeDestOut BlendMode = C.VIPS_BLEND_MODE_DEST_OUT BlendModeDestAtop BlendMode = C.VIPS_BLEND_MODE_DEST_ATOP BlendModeXOR BlendMode = C.VIPS_BLEND_MODE_XOR BlendModeAdd BlendMode = C.VIPS_BLEND_MODE_ADD BlendModeSaturate BlendMode = C.VIPS_BLEND_MODE_SATURATE BlendModeMultiply BlendMode = C.VIPS_BLEND_MODE_MULTIPLY BlendModeScreen BlendMode = C.VIPS_BLEND_MODE_SCREEN BlendModeOverlay BlendMode = C.VIPS_BLEND_MODE_OVERLAY BlendModeDarken BlendMode = C.VIPS_BLEND_MODE_DARKEN BlendModeLighten BlendMode = C.VIPS_BLEND_MODE_LIGHTEN BlendModeColorDodge BlendMode = C.VIPS_BLEND_MODE_COLOUR_DODGE BlendModeColorBurn BlendMode = C.VIPS_BLEND_MODE_COLOUR_BURN BlendModeHardLight BlendMode = C.VIPS_BLEND_MODE_HARD_LIGHT BlendModeSoftLight BlendMode = C.VIPS_BLEND_MODE_SOFT_LIGHT BlendModeDifference BlendMode = C.VIPS_BLEND_MODE_DIFFERENCE BlendModeExclusion BlendMode = C.VIPS_BLEND_MODE_EXCLUSION )
Constants define the various Porter-Duff and PDF blend modes. See https://libvips.github.io/libvips/API/current/libvips-conversion.html#VipsBlendMode
type Coding ¶
type Coding int
Coding represents VIPS_CODING type
const ( CodingError Coding = C.VIPS_CODING_ERROR CodingNone Coding = C.VIPS_CODING_NONE CodingLABQ Coding = C.VIPS_CODING_LABQ CodingRAD Coding = C.VIPS_CODING_RAD )
Coding enum
type ColorRGBA ¶
type ColorRGBA struct {
R, G, B, A uint8
}
ColorRGBA represents an RGB with alpha channel (A)
type Config ¶
type Config struct { ConcurrencyLevel int MaxCacheFiles int MaxCacheMem int MaxCacheSize int ReportLeaks bool CacheTrace bool CollectStats bool }
Config allows fine-tuning of libvips library
type Direction ¶
type Direction int
Direction represents VIPS_DIRECTION type
const ( DirectionHorizontal Direction = C.VIPS_DIRECTION_HORIZONTAL DirectionVertical Direction = C.VIPS_DIRECTION_VERTICAL )
Direction enum
type ExportParams ¶
type ExportParams struct { Format ImageType Quality int Compression int Interlaced bool Lossless bool Effort int StripMetadata bool }
ExportParams are options when exporting an image to file or buffer. Deprecated: Use format-specific params
func NewDefaultExportParams ¶
func NewDefaultExportParams() *ExportParams
NewDefaultExportParams creates default values for an export when image type is not JPEG, PNG or WEBP. By default, govips creates interlaced, lossy images with a quality of 80/100 and compression of 6/10. As these are default values for a wide variety of image formats, their application varies. Some formats use the quality parameters, some compression, etc. Deprecated: Use format-specific params
func NewDefaultJPEGExportParams ¶
func NewDefaultJPEGExportParams() *ExportParams
NewDefaultJPEGExportParams creates default values for an export of a JPEG image. By default, govips creates interlaced JPEGs with a quality of 80/100. Deprecated: Use NewJpegExportParams
func NewDefaultPNGExportParams ¶
func NewDefaultPNGExportParams() *ExportParams
NewDefaultPNGExportParams creates default values for an export of a PNG image. By default, govips creates non-interlaced PNGs with a compression of 6/10. Deprecated: Use NewPngExportParams
func NewDefaultWEBPExportParams ¶
func NewDefaultWEBPExportParams() *ExportParams
NewDefaultWEBPExportParams creates default values for an export of a WEBP image. By default, govips creates lossy images with a quality of 75/100. Deprecated: Use NewWebpExportParams
type ExtendStrategy ¶
type ExtendStrategy int
ExtendStrategy represents VIPS_EXTEND type
const ( ExtendBlack ExtendStrategy = C.VIPS_EXTEND_BLACK ExtendCopy ExtendStrategy = C.VIPS_EXTEND_COPY ExtendRepeat ExtendStrategy = C.VIPS_EXTEND_REPEAT ExtendMirror ExtendStrategy = C.VIPS_EXTEND_MIRROR ExtendWhite ExtendStrategy = C.VIPS_EXTEND_WHITE ExtendBackground ExtendStrategy = C.VIPS_EXTEND_BACKGROUND )
ExtendStrategy enum
type HeifExportParams ¶
HeifExportParams are options when exporting a HEIF to file or buffer
func NewHeifExportParams ¶
func NewHeifExportParams() *HeifExportParams
NewHeifExportParams creates default values for an export of a HEIF image.
type ImageComposite ¶
ImageComposite image to composite param
type ImageMetadata ¶
type ImageMetadata struct { Format ImageType Width int Height int Colorspace Interpretation Orientation int }
ImageMetadata is a data structure holding the width, height, orientation and other metadata of the picture.
type ImageRef ¶
type ImageRef struct {
// contains filtered or unexported fields
}
ImageRef contains a libvips image and manages its lifecycle. You need to close an image when done or it will leak
func Identity ¶
Identity creates an identity lookup table, which will leave an image unchanged when applied with Maplut. Each entry in the table has a value equal to its position.
func NewImageFromBuffer ¶
NewImageFromBuffer loads an image buffer and creates a new Image
func NewImageFromFile ¶
NewImageFromFile loads an image from file and creates a new ImageRef
func NewImageFromReader ¶
NewImageFromReader loads an ImageRef from the given reader
func XYZ ¶
XYZ creates a two-band uint32 image where the elements in the first band have the value of their x coordinate and elements in the second band have their y coordinate.
func (*ImageRef) AutoRotate ¶
AutoRotate rotates the image upright based on the EXIF Orientation tag. It also resets the orientation information in the EXIF tag to be 1 (i.e. upright). N.B. libvips does not flip images currently (i.e. no support for orientations 2, 4, 5 and 7). N.B. due to the HEIF image standard, HEIF images are always autorotated by default on load. Thus, calling AutoRotate for HEIF images is not needed.
func (*ImageRef) BandFormat ¶
func (r *ImageRef) BandFormat() BandFormat
BandFormat returns the current band format
func (*ImageRef) BandJoinConst ¶
BandJoinConst appends a set of constant bands to an image.
func (*ImageRef) Cast ¶
func (r *ImageRef) Cast(format BandFormat) error
Cast converts the image to a target band format
func (*ImageRef) Close ¶
func (r *ImageRef) Close()
Close manually closes the image and frees the memory. Calling Close() is optional. Images are automatically closed by GC. However, in high volume applications the GC can't keep up with the amount of memory so you might want to manually close the images.
func (*ImageRef) ColorSpace ¶
func (r *ImageRef) ColorSpace() Interpretation
ColorSpace returns the interpreptation of the current color space. Alias to Interpretation().
func (*ImageRef) Composite ¶
Composite composites the given overlay image on top of the associated image with provided blending mode.
func (*ImageRef) CompositeMulti ¶
func (r *ImageRef) CompositeMulti(ins []*ImageComposite) error
CompositeMulti composites the given overlay image on top of the associated image with provided blending mode.
func (*ImageRef) CopyMemory ¶
func (*ImageRef) Divide ¶
Divide calculates the product of the image / denominator and stores it back in the image
func (*ImageRef) DrawRect ¶
func (r *ImageRef) DrawRect(ink ColorRGBA, left int, top int, width int, height int, fill bool) error
DrawRect draws an (optionally filled) rectangle with a single colour
func (*ImageRef) Embed ¶
func (r *ImageRef) Embed(left, top, width, height int, extend ExtendStrategy) error
Embed embeds the given picture in a new one, i.e. the opposite of ExtractArea
func (*ImageRef) Export ¶
func (r *ImageRef) Export(params *ExportParams) ([]byte, *ImageMetadata, error)
Export creates a byte array of the image for use. The function returns a byte array that can be written to a file e.g. via ioutil.WriteFile(). N.B. govips does not currently have built-in support for directly exporting to a file. The function also returns a copy of the image metadata as well as an error. Deprecated: Use ExportNative or format-specific Export methods
func (*ImageRef) ExportHeif ¶
func (r *ImageRef) ExportHeif(params *HeifExportParams) ([]byte, *ImageMetadata, error)
ExportHeif exports the image as HEIF to a buffer.
func (*ImageRef) ExportJpeg ¶
func (r *ImageRef) ExportJpeg(params *JpegExportParams) ([]byte, *ImageMetadata, error)
ExportJpeg exports the image as JPEG to a buffer.
func (*ImageRef) ExportNative ¶
func (r *ImageRef) ExportNative() ([]byte, *ImageMetadata, error)
ExportNative exports the image to a buffer based on its native format with default parameters.
func (*ImageRef) ExportPng ¶
func (r *ImageRef) ExportPng(params *PngExportParams) ([]byte, *ImageMetadata, error)
ExportPng exports the image as PNG to a buffer.
func (*ImageRef) ExportTiff ¶
func (r *ImageRef) ExportTiff(params *TiffExportParams) ([]byte, *ImageMetadata, error)
ExportTiff exports the image as TIFF to a buffer.
func (*ImageRef) ExportWebp ¶
func (r *ImageRef) ExportWebp(params *WebpExportParams) ([]byte, *ImageMetadata, error)
ExportWebp exports the image as WEBP to a buffer.
func (*ImageRef) ExtractArea ¶
ExtractArea crops the image to a specified area
func (*ImageRef) ExtractBand ¶
ExtractBand extracts one or more bands out of the image (replacing the associated ImageRef)
func (*ImageRef) Flatten ¶
Flatten removes the alpha channel from the image and replaces it with the background color
func (*ImageRef) Flip ¶
Flip flips the image either horizontally or vertically based on the parameter
func (*ImageRef) GaussianBlur ¶
Gaussblur executes the 'gaussblur' operation
func (*ImageRef) GetOrientation ¶
GetOrientation returns the orientation number as it appears in the EXIF, if present
func (*ImageRef) HasICCProfile ¶
HasICCProfile checks whether the image has an ICC profile embedded. Alias to HasProfile
func (*ImageRef) HasIPTC ¶
HasIPTC returns a boolean whether the image in question has IPTC data associated with it.
func (*ImageRef) HasProfile ¶
HasProfile returns if the image has an ICC profile embedded.
func (*ImageRef) Interpretation ¶
func (r *ImageRef) Interpretation() Interpretation
Interpretation returns the current interpretation of the color space of the image.
func (*ImageRef) IsColorSpaceSupported ¶
IsColorSpaceSupported returns a boolean whether the image's color space is supported by libvips.
func (*ImageRef) Label ¶
func (r *ImageRef) Label(labelParams *LabelParams) error
Label overlays a label on top of the image
func (*ImageRef) Linear ¶
Linear passes an image through a linear transformation (ie. output = input * a + b). See https://libvips.github.io/libvips/API/current/libvips-arithmetic.html#vips-linear
func (*ImageRef) Linear1 ¶
Linear1 runs Linear() with a single constant. See https://libvips.github.io/libvips/API/current/libvips-arithmetic.html#vips-linear1
func (*ImageRef) Maplut ¶
Maplut maps an image through another image acting as a LUT (Look Up Table)
func (*ImageRef) Metadata ¶
func (r *ImageRef) Metadata() *ImageMetadata
Metadata returns the metadata (ImageMetadata struct) of the associated ImageRef
func (*ImageRef) ModulateHSV ¶
ModulateHSV modulates the image HSV values based on the supplier parameters.
func (*ImageRef) Multiply ¶
Multiply calculates the product of the image * multiplier and stores it back in the image
func (*ImageRef) OptimizeICCProfile ¶
func (*ImageRef) PremultiplyAlpha ¶
PremultiplyAlpha premultiplies the alpha channel. See https://libvips.github.io/libvips/API/current/libvips-conversion.html#vips-premultiply
func (*ImageRef) RemoveICCProfile ¶
RemoveICCProfile removes the ICC Profile information from the image. Typically browsers and other software assume images without profile to be in the sRGB color space.
func (*ImageRef) RemoveMetadata ¶
RemoveMetadata removes the EXIF metadata from the image. N.B. this function won't remove the ICC profile and orientation because govips needs it to correctly display the image.
func (*ImageRef) RemoveOrientation ¶
RemoveOrientation removes the EXIF orientation information of the image.
func (*ImageRef) ResizeWithVScale ¶
ResizeWithVScale resizes the image with both horizontal as well as vertical scaling. The parameters are the scaling factors.
func (*ImageRef) Rotate ¶
Rotate rotates the image by multiples of 90 degrees. To rotate by arbitrary angles use Similarity.
func (*ImageRef) SetOrientation ¶
SetOrientation sets the orientation in the EXIF header of the associated image.
func (*ImageRef) Sharpen ¶
Sharpen sharpens the image sigma: sigma of the gaussian x1: flat/jaggy threshold m2: slope for jaggy areas
func (*ImageRef) Similarity ¶
func (r *ImageRef) Similarity(scale float64, angle float64, backgroundColor *ColorRGBA, idx float64, idy float64, odx float64, ody float64) error
Similarity lets you scale, offset and rotate images by arbitrary angles in a single operation while defining the color of new background pixels. If the input image has no alpha channel, the alpha on `backgroundColor` will be ignored. You can add an alpha channel to an image with `BandJoinConst` (e.g. `img.BandJoinConst([]float64{255})`) or AddAlpha.
func (*ImageRef) SmartCrop ¶
func (r *ImageRef) SmartCrop(width int, height int, interesting Interesting) error
SmartCrop will crop the image based on interestingness factor
func (*ImageRef) Thumbnail ¶
func (r *ImageRef) Thumbnail(width, height int, crop Interesting) error
Thumbnail resizes the image to the given width and height. If crop is true the returned image size will be exactly the given height and width, otherwise the width and height will be within the given parameters.
func (*ImageRef) ToBytes ¶
ToBytes writes the image to memory in VIPs format and returns the raw bytes, useful for storage.
func (*ImageRef) ToColorSpace ¶
func (r *ImageRef) ToColorSpace(interpretation Interpretation) error
ToColorSpace changes the color space of the image to the interpreptation supplied as the parameter.
func (*ImageRef) ToImage ¶
func (r *ImageRef) ToImage(params *ExportParams) (image.Image, error)
ToImage converts a VIPs image to a golang image.Image object, useful for interoperability with other golang libraries
func (*ImageRef) UnpremultiplyAlpha ¶
UnpremultiplyAlpha unpremultiplies any alpha channel. See https://libvips.github.io/libvips/API/current/libvips-conversion.html#vips-unpremultiply
type ImageType ¶
type ImageType int
ImageType represents an image type
const ( ImageTypeUnknown ImageType = C.UNKNOWN ImageTypeGIF ImageType = C.GIF ImageTypeJPEG ImageType = C.JPEG ImageTypeMagick ImageType = C.MAGICK ImageTypePDF ImageType = C.PDF ImageTypePNG ImageType = C.PNG ImageTypeSVG ImageType = C.SVG ImageTypeTIFF ImageType = C.TIFF ImageTypeWEBP ImageType = C.WEBP ImageTypeHEIF ImageType = C.HEIF ImageTypeBMP ImageType = C.BMP )
ImageType enum
func DetermineImageType ¶
DetermineImageType attempts to determine the image type of the given buffer
type Intent ¶
type Intent int
Intent represents VIPS_INTENT type
const ( IntentPerceptual Intent = C.VIPS_INTENT_PERCEPTUAL IntentRelative Intent = C.VIPS_INTENT_RELATIVE IntentSaturation Intent = C.VIPS_INTENT_SATURATION IntentAbsolute Intent = C.VIPS_INTENT_ABSOLUTE IntentLast Intent = C.VIPS_INTENT_LAST )
Intent enum
type Interesting ¶
type Interesting int
Interesting represents VIPS_INTERESTING type https://libvips.github.io/libvips/API/current/libvips-conversion.html#VipsInteresting
const ( InterestingNone Interesting = C.VIPS_INTERESTING_NONE InterestingCentre Interesting = C.VIPS_INTERESTING_CENTRE InterestingEntropy Interesting = C.VIPS_INTERESTING_ENTROPY InterestingAttention Interesting = C.VIPS_INTERESTING_ATTENTION InterestingLow Interesting = C.VIPS_INTERESTING_LOW InterestingHigh Interesting = C.VIPS_INTERESTING_HIGH InterestingAll Interesting = C.VIPS_INTERESTING_ALL InterestingLast Interesting = C.VIPS_INTERESTING_LAST )
Interesting constants represent areas of interest which smart cropping will crop based on.
type Interpretation ¶
type Interpretation int
Interpretation represents VIPS_INTERPRETATION type
const ( InterpretationError Interpretation = C.VIPS_INTERPRETATION_ERROR InterpretationMultiband Interpretation = C.VIPS_INTERPRETATION_MULTIBAND InterpretationBW Interpretation = C.VIPS_INTERPRETATION_B_W InterpretationHistogram Interpretation = C.VIPS_INTERPRETATION_HISTOGRAM InterpretationXYZ Interpretation = C.VIPS_INTERPRETATION_XYZ InterpretationLAB Interpretation = C.VIPS_INTERPRETATION_LAB InterpretationCMYK Interpretation = C.VIPS_INTERPRETATION_CMYK InterpretationLABQ Interpretation = C.VIPS_INTERPRETATION_LABQ InterpretationRGB Interpretation = C.VIPS_INTERPRETATION_RGB InterpretationRGB16 Interpretation = C.VIPS_INTERPRETATION_RGB16 InterpretationCMC Interpretation = C.VIPS_INTERPRETATION_CMC InterpretationLCH Interpretation = C.VIPS_INTERPRETATION_LCH InterpretationLABS Interpretation = C.VIPS_INTERPRETATION_LABS InterpretationSRGB Interpretation = C.VIPS_INTERPRETATION_sRGB InterpretationYXY Interpretation = C.VIPS_INTERPRETATION_YXY InterpretationFourier Interpretation = C.VIPS_INTERPRETATION_FOURIER InterpretationGB16 Interpretation = C.VIPS_INTERPRETATION_RGB16 InterpretationGrey16 Interpretation = C.VIPS_INTERPRETATION_GREY16 InterpretationMatrix Interpretation = C.VIPS_INTERPRETATION_MATRIX InterpretationScRGB Interpretation = C.VIPS_INTERPRETATION_scRGB InterpretationHSV Interpretation = C.VIPS_INTERPRETATION_HSV )
Interpretation enum
type JpegExportParams ¶
type JpegExportParams struct { StripMetadata bool Quality int Interlace bool OptimizeCoding bool Subsampling JpegSubsampling }
JpegExportParams are options when exporting a JPEG to file or buffer
func NewJpegExportParams ¶
func NewJpegExportParams() *JpegExportParams
NewJpegExportParams creates default values for an export of a JPEG image. By default, govips creates interlaced JPEGs with a quality of 80/100.
type JpegSubsampling ¶
type JpegSubsampling int
const ( JpegSubsamplingAuto JpegSubsampling = 0 JpegSubsamplingOn JpegSubsampling = 1 JpegSubsamplingOff JpegSubsampling = 2 JpegSubsamplingLast JpegSubsampling = 3 )
type Kernel ¶
type Kernel int
Kernel represents VipsKernel type
const ( KernelAuto Kernel = -1 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 KernelMitchell Kernel = C.VIPS_KERNEL_MITCHELL )
Kernel enum
type LabelParams ¶
type LabelParams struct { Text string Font string Width Scalar Height Scalar OffsetX Scalar OffsetY Scalar Opacity float32 Color Color Alignment Align }
LabelParams represents a text-based label
type LogLevel ¶
type LogLevel int
LogLevel is the enum controlling logging message verbosity.
const ( LogLevelError LogLevel = C.G_LOG_LEVEL_ERROR LogLevelCritical LogLevel = C.G_LOG_LEVEL_CRITICAL LogLevelWarning LogLevel = C.G_LOG_LEVEL_WARNING LogLevelMessage LogLevel = C.G_LOG_LEVEL_MESSAGE LogLevelInfo LogLevel = C.G_LOG_LEVEL_INFO LogLevelDebug LogLevel = C.G_LOG_LEVEL_DEBUG )
The logging verbosity levels classify and filter logging messages. From most to least verbose, they are debug, info, message, warning, critical and error.
type LoggingHandlerFunction ¶
LoggingHandlerFunction is a function which will be called for each log message. By default, govips sends logging messages to os.Stderr. If you want to log elsewhere such as to a file or to a state variable which you inspect yourself, define a new logging handler function and set it via LoggingSettings().
type MemoryStats ¶
MemoryStats is a data structure that houses various memory statistics from ReadVipsMemStats()
type PngExportParams ¶
PngExportParams are options when exporting a PNG to file or buffer
func NewPngExportParams ¶
func NewPngExportParams() *PngExportParams
NewPngExportParams creates default values for an export of a PNG image. By default, govips creates non-interlaced PNGs with a compression of 6/10.
type PreMultiplicationState ¶
type PreMultiplicationState struct {
// contains filtered or unexported fields
}
PreMultiplicationState stores the premultiplication band format of the image
type Precision ¶
type Precision int
Precision represents VipsPrecision type https://libvips.github.io/libvips/API/current/libvips-basic.html#VipsPrecision
const ( PrecisionInteger Precision = C.VIPS_PRECISION_INTEGER PrecisionFloat Precision = C.VIPS_PRECISION_FLOAT PrecisionApproximate Precision = C.VIPS_PRECISION_APPROXIMATE PrecisionLast Precision = C.VIPS_PRECISION_LAST )
Precision enum
type RuntimeStats ¶
RuntimeStats is a data structure to house a map of govips operation counts
type Scalar ¶
Scalar is the basic scalar measurement of an image's height, width or offset coordinate.
func (*Scalar) Get ¶
Get returns the value of the scalar. Either absolute, or if relative, multiplied by the base given as parameter.
func (*Scalar) GetRounded ¶
GetRounded returns the value of the associated Scalar, rounded to the nearest integer, if absolute. If the Scalar is relative, it will be multiplied by the supplied base parameter.
type TiffCompression ¶
type TiffCompression int
TiffCompression represents method for compressing a tiff at export
const ( TiffCompressionNone TiffCompression = C.VIPS_FOREIGN_TIFF_COMPRESSION_NONE TiffCompressionJpeg TiffCompression = C.VIPS_FOREIGN_TIFF_COMPRESSION_JPEG TiffCompressionDeflate TiffCompression = C.VIPS_FOREIGN_TIFF_COMPRESSION_DEFLATE TiffCompressionPackbits TiffCompression = C.VIPS_FOREIGN_TIFF_COMPRESSION_PACKBITS TiffCompressionFax4 TiffCompression = C.VIPS_FOREIGN_TIFF_COMPRESSION_CCITTFAX4 TiffCompressionLzw TiffCompression = C.VIPS_FOREIGN_TIFF_COMPRESSION_LZW TiffCompressionWebp TiffCompression = C.VIPS_FOREIGN_TIFF_COMPRESSION_WEBP TiffCompressionZstd TiffCompression = C.VIPS_FOREIGN_TIFF_COMPRESSION_ZSTD )
TiffCompression enum
type TiffExportParams ¶
type TiffExportParams struct { StripMetadata bool Quality int Compression TiffCompression Predictor TiffPredictor }
TiffExportParams are options when exporting a TIFF to file or buffer
func NewTiffExportParams ¶
func NewTiffExportParams() *TiffExportParams
NewTiffExportParams creates default values for an export of a TIFF image.
type TiffPredictor ¶
type TiffPredictor int
TiffPredictor represents method for compressing a tiff at export
const ( TiffPredictorNone TiffPredictor = C.VIPS_FOREIGN_TIFF_PREDICTOR_NONE TiffPredictorHorizontal TiffPredictor = C.VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL TiffPredictorFloat TiffPredictor = C.VIPS_FOREIGN_TIFF_PREDICTOR_FLOAT )
TiffPredictor enum
type WebpExportParams ¶
type WebpExportParams struct { StripMetadata bool Quality int Lossless bool NearLossless bool ReductionEffort int IccProfile string }
WebpExportParams are options when exporting a WEBP to file or buffer
func NewWebpExportParams ¶
func NewWebpExportParams() *WebpExportParams
NewWebpExportParams creates default values for an export of a WEBP image. By default, govips creates lossy images with a quality of 75/100.