Documentation ¶
Index ¶
- Constants
- Variables
- func ColourspaceIsSupported(buf []byte) (bool, error)
- func DetermineImageTypeName(buf []byte) string
- func ImageTypeName(t ImageType) string
- func Initialize()
- func IsSVGImage(buf []byte) bool
- func IsTypeNameSupported(t string) bool
- func IsTypeNameSupportedSave(t string) bool
- func IsTypeSupported(t ImageType) bool
- func IsTypeSupportedSave(t ImageType) bool
- func Read(path string) ([]byte, error)
- func Resize(buf []byte, o Options) ([]byte, error)
- func Shutdown()
- func VipsDebugInfo()
- func VipsIsTypeSupported(t ImageType) bool
- func VipsIsTypeSupportedSave(t ImageType) bool
- func Write(path string, buf []byte) error
- type Angle
- type Color
- type Direction
- type Extend
- type GaussianBlur
- type Gravity
- type Image
- func (i *Image) Colourspace(c Interpretation) ([]byte, error)
- func (i *Image) ColourspaceIsSupported() (bool, error)
- func (i *Image) Convert(t ImageType) ([]byte, error)
- func (i *Image) Crop(width, height int, gravity Gravity) ([]byte, error)
- func (i *Image) CropByHeight(height int) ([]byte, error)
- func (i *Image) CropByWidth(width int) ([]byte, error)
- func (i *Image) Enlarge(width, height int) ([]byte, error)
- func (i *Image) EnlargeAndCrop(width, height int) ([]byte, error)
- func (i *Image) Extract(top, left, width, height int) ([]byte, error)
- func (i *Image) Flip() ([]byte, error)
- func (i *Image) Flop() ([]byte, error)
- func (i *Image) ForceResize(width, height int) ([]byte, error)
- func (i *Image) Image() []byte
- func (i *Image) Interpretation() (Interpretation, error)
- func (i *Image) Metadata() (ImageMetadata, error)
- func (i *Image) Process(o Options) ([]byte, error)
- func (i *Image) Resize(width, height int) ([]byte, error)
- func (i *Image) ResizeAndCrop(width, height int) ([]byte, error)
- func (i *Image) Rotate(a Angle) ([]byte, error)
- func (i *Image) Size() (ImageSize, error)
- func (i *Image) Thumbnail(pixels int) ([]byte, error)
- func (i *Image) Type() string
- func (i *Image) Watermark(w Watermark) ([]byte, error)
- func (i *Image) Zoom(factor int) ([]byte, error)
- type ImageMetadata
- type ImageSize
- type ImageType
- type Interpolator
- type Interpretation
- type Options
- type Sharpen
- type SupportedImageType
- type VipsMemoryInfo
- type Watermark
Constants ¶
const ( // Quality defines the default JPEG quality to be used. Quality = 80 // MaxSize defines the maximum pixels width or height supported. MaxSize = 16383 )
const Version = "1.0.7"
Version represents the current package semantic version.
const VipsMajorVersion = int(C.VIPS_MAJOR_VERSION)
VipsMajorVersion exposes the current libvips major version number
const VipsMinorVersion = int(C.VIPS_MINOR_VERSION)
VipsMinorVersion exposes the current libvips minor version number
const VipsVersion = string(C.VIPS_VERSION)
VipsVersion exposes the current libvips semantic version
Variables ¶
var ColorBlack = Color{0, 0, 0}
ColorBlack is a shortcut to black RGB color representation.
var ImageTypes = map[ImageType]string{ JPEG: "jpeg", PNG: "png", WEBP: "webp", TIFF: "tiff", GIF: "gif", PDF: "pdf", SVG: "svg", MAGICK: "magick", }
ImageTypes stores as pairs of image types supported and its alias names.
var SupportedImageTypes = map[ImageType]SupportedImageType{}
SupportedImageTypes stores the optional image type supported by the current libvips compilation. Note: lazy evaluation as demand is required due to bootstrap runtime limitation with C/libvips world.
var WatermarkFont = "sans 10"
WatermarkFont defines the default watermark font to be used.
Functions ¶
func ColourspaceIsSupported ¶
ColourspaceIsSupported checks if the image colourspace is supported by libvips.
func DetermineImageTypeName ¶
DetermineImageTypeName determines the image type format by name (jpeg, png, webp or tiff)
func ImageTypeName ¶
ImageTypeName is used to get the human friendly name of an image format.
func Initialize ¶
func Initialize()
Initialize is used to explicitly start libvips in thread-safe way. Only call this function if you have previously turned off libvips.
func IsSVGImage ¶ added in v1.0.3
IsSVGImage returns true if the given buffer is a valid SVG image.
func IsTypeNameSupported ¶
IsTypeNameSupported checks if a given image type name is supported
func IsTypeNameSupportedSave ¶ added in v1.0.7
IsTypeNameSupportedSave checks if a given image type name is supported for saving
func IsTypeSupported ¶
IsTypeSupported checks if a given image type is supported
func IsTypeSupportedSave ¶ added in v1.0.7
IsTypeSupportedSave checks if a given image type is support for saving
func Shutdown ¶
func Shutdown()
Shutdown is used to shutdown libvips in a thread-safe way. You can call this to drop caches as well. If libvips was already initialized, the function is no-op
func VipsDebugInfo ¶
func VipsDebugInfo()
VipsDebugInfo outputs to stdout libvips collected data. Useful for debugging.
func VipsIsTypeSupported ¶ added in v1.0.3
VipsIsTypeSupported returns true if the given image type is supported by the current libvips compilation.
func VipsIsTypeSupportedSave ¶ added in v1.0.7
VipsIsTypeSupportedSave returns true if the given image type is supported by the current libvips compilation for the save operation.
Types ¶
type Angle ¶
type Angle int
Angle represents the image rotation angle value.
const ( // D0 represents the rotation angle 0 degrees. D0 Angle = 0 // D45 represents the rotation angle 90 degrees. D45 Angle = 45 // D90 represents the rotation angle 90 degrees. D90 Angle = 90 // D135 represents the rotation angle 90 degrees. D135 Angle = 135 // D180 represents the rotation angle 180 degrees. D180 Angle = 180 // D235 represents the rotation angle 235 degrees. D235 Angle = 235 // D270 represents the rotation angle 270 degrees. D270 Angle = 270 // D315 represents the rotation angle 180 degrees. D315 Angle = 315 )
type Direction ¶
type Direction int
Direction represents the image direction value.
const ( // Horizontal represents the orizontal image direction value. Horizontal Direction = C.VIPS_DIRECTION_HORIZONTAL // Vertical represents the vertical image direction value. Vertical Direction = C.VIPS_DIRECTION_VERTICAL )
type Extend ¶ added in v1.0.5
type Extend int
Extend represents the image extend mode, used when the edges of an image are extended, you can specify how you want the extension done. See: http://www.vips.ecs.soton.ac.uk/supported/8.4/doc/html/libvips/libvips-conversion.html#VIPS-EXTEND-BACKGROUND:CAPS
const ( // ExtendBlack extend with black (all 0) pixels mode. ExtendBlack Extend = C.VIPS_EXTEND_BLACK // ExtendCopy copy the image edges. ExtendCopy Extend = C.VIPS_EXTEND_COPY // ExtendRepeat repeat the whole image. ExtendRepeat Extend = C.VIPS_EXTEND_REPEAT // ExtendMirror mirror the whole image. ExtendMirror Extend = C.VIPS_EXTEND_MIRROR // ExtendWhite extend with white (all bits set) pixels. ExtendWhite Extend = C.VIPS_EXTEND_WHITE // ExtendBackground with colour from the background property. ExtendBackground Extend = C.VIPS_EXTEND_BACKGROUND // ExtendLast extend with last pixel. ExtendLast Extend = C.VIPS_EXTEND_LAST )
type GaussianBlur ¶
GaussianBlur represents the gaussian image transformation values.
type Gravity ¶
type Gravity int
Gravity represents the image gravity value.
const ( // GravityCentre represents the centre value used for image gravity orientation. GravityCentre Gravity = iota // GravityNorth represents the north value used for image gravity orientation. GravityNorth // GravityEast represents the east value used for image gravity orientation. GravityEast // GravitySouth represents the south value used for image gravity orientation. GravitySouth // GravityWest represents the west value used for image gravity orientation. GravityWest )
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image provides a simple method DSL to transform a given image as byte buffer.
func (*Image) Colourspace ¶
func (i *Image) Colourspace(c Interpretation) ([]byte, error)
Colourspace performs a color space conversion bsaed on the given interpretation.
func (*Image) ColourspaceIsSupported ¶
ColourspaceIsSupported checks if the current image color space is supported.
func (*Image) CropByHeight ¶
CropByHeight crops an image by height (auto width).
func (*Image) CropByWidth ¶
CropByWidth crops an image by width only param (auto height).
func (*Image) EnlargeAndCrop ¶
EnlargeAndCrop enlarges the image by width and height with additional crop transformation.
func (*Image) ForceResize ¶
ForceResize resizes with custom size (aspect ratio won't be maintained).
func (*Image) Interpretation ¶
func (i *Image) Interpretation() (Interpretation, error)
Interpretation gets the image interpretation type. See: http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/libvips/VipsImage.html#VipsInterpretation
func (*Image) Metadata ¶
func (i *Image) Metadata() (ImageMetadata, error)
Metadata returns the image metadata (size, alpha channel, profile, EXIF rotation).
func (*Image) Process ¶
Process processes the image based on the given transformation options, talking with libvips bindings accordingly and returning the resultant image buffer.
func (*Image) ResizeAndCrop ¶
ResizeAndCrop resizes the image to fixed width and height with additional crop transformation.
func (*Image) Thumbnail ¶
Thumbnail creates a thumbnail of the image by the a given width by aspect ratio 4:4.
type ImageMetadata ¶
type ImageMetadata struct { Orientation int Channels int Alpha bool Profile bool Type string Space string Colourspace string Size ImageSize }
ImageMetadata represents the basic metadata fields
func Metadata ¶
func Metadata(buf []byte) (ImageMetadata, error)
Metadata returns the image metadata (size, type, alpha channel, profile, EXIF orientation...).
type ImageType ¶
type ImageType int
ImageType represents an image type value.
const ( // UNKNOWN represents an unknow image type value. UNKNOWN ImageType = iota // JPEG represents the JPEG image type. JPEG // WEBP represents the WEBP image type. WEBP // PNG represents the PNG image type. PNG // TIFF represents the TIFF image type. TIFF // GIF represents the GIF image type. GIF // PDF represents the PDF type. PDF // SVG represents the SVG image type. SVG // MAGICK represents the libmagick compatible genetic image type. MAGICK )
func DetermineImageType ¶
DetermineImageType determines the image type format (jpeg, png, webp or tiff)
type Interpolator ¶
type Interpolator int
Interpolator represents the image interpolation value.
const ( // Bicubic interpolation value. Bicubic Interpolator = iota // Bilinear interpolation value. Bilinear // Nohalo interpolation value. Nohalo )
func (Interpolator) String ¶
func (i Interpolator) String() string
type Interpretation ¶
type Interpretation int
Interpretation represents the image interpretation type. See: http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/libvips/VipsImage.html#VipsInterpretation
const ( // InterpretationError points to the libvips interpretation error type. InterpretationError Interpretation = C.VIPS_INTERPRETATION_ERROR // InterpretationMultiband points to its libvips interpretation equivalent type. InterpretationMultiband Interpretation = C.VIPS_INTERPRETATION_MULTIBAND // InterpretationBW points to its libvips interpretation equivalent type. InterpretationBW Interpretation = C.VIPS_INTERPRETATION_B_W // InterpretationCMYK points to its libvips interpretation equivalent type. InterpretationCMYK Interpretation = C.VIPS_INTERPRETATION_CMYK // InterpretationRGB points to its libvips interpretation equivalent type. InterpretationRGB Interpretation = C.VIPS_INTERPRETATION_RGB // InterpretationSRGB points to its libvips interpretation equivalent type. InterpretationSRGB Interpretation = C.VIPS_INTERPRETATION_sRGB // InterpretationRGB16 points to its libvips interpretation equivalent type. InterpretationRGB16 Interpretation = C.VIPS_INTERPRETATION_RGB16 // InterpretationGREY16 points to its libvips interpretation equivalent type. InterpretationGREY16 Interpretation = C.VIPS_INTERPRETATION_GREY16 // InterpretationScRGB points to its libvips interpretation equivalent type. InterpretationScRGB Interpretation = C.VIPS_INTERPRETATION_scRGB // InterpretationLAB points to its libvips interpretation equivalent type. InterpretationLAB Interpretation = C.VIPS_INTERPRETATION_LAB // InterpretationXYZ points to its libvips interpretation equivalent type. InterpretationXYZ Interpretation = C.VIPS_INTERPRETATION_XYZ )
func ImageInterpretation ¶
func ImageInterpretation(buf []byte) (Interpretation, error)
ImageInterpretation returns the image interpretation type. See: http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/libvips/VipsImage.html#VipsInterpretation
type Options ¶
type Options struct { Height int Width int AreaHeight int AreaWidth int Top int Left int Quality int Compression int Zoom int Crop bool Enlarge bool Embed bool Flip bool Flop bool Force bool NoAutoRotate bool NoProfile bool Interlace bool Extend Extend Rotate Angle Background Color Gravity Gravity Watermark Watermark Type ImageType Interpolator Interpolator Interpretation Interpretation GaussianBlur GaussianBlur Sharpen Sharpen }
Options represents the supported image transformation options.
type SupportedImageType ¶ added in v1.0.7
SupportedImageType represents whether a type can be loaded and/or saved by the current libvips compilation.
func IsImageTypeSupportedByVips ¶ added in v1.0.3
func IsImageTypeSupportedByVips(t ImageType) SupportedImageType
IsImageTypeSupportedByVips returns true if the given image type is supported by current libvips compilation.
type VipsMemoryInfo ¶
VipsMemoryInfo represents the memory stats provided by libvips.
func VipsMemory ¶
func VipsMemory() VipsMemoryInfo
VipsMemory gets memory info stats from libvips (cache size, memory allocs...)