Documentation ¶
Index ¶
- Constants
- Variables
- func IsAnimationSupported(imageType ImageType) bool
- func IsLoadSupported(imageType ImageType) bool
- func IsSaveSupported(imageType ImageType) bool
- func ReadVipsMemStats(stats *MemoryStats)
- func SetLogging(handler LoggingHandlerFunction, verbosity LogLevel)
- func Shutdown()
- func Startup(config *Config)
- func WrapErr(err error) error
- type Align
- type Angle
- type Angle45
- type AvifExportParams
- type BlendMode
- type BoolParam
- type Color
- type ColorRGBA
- type Config
- type Direction
- type ExtendStrategy
- type FilterFunc
- type FilterMap
- type GifExportParams
- type HeifExportParams
- type Image
- func LoadImageFromBuffer(buf []byte, params *ImportParams) (*Image, error)
- func LoadImageFromMemory(buf []byte, width, height, bands int) (*Image, error)
- func LoadImageFromSource(s *Source, params *ImportParams) (*Image, error)
- func LoadThumbnailFromSource(s *Source, width, height int, crop Interesting, size Size, ...) (*Image, error)
- func (r *Image) AddAlpha() error
- func (r *Image) Bands() int
- func (r *Image) Close()
- func (r *Image) ColorSpace() Interpretation
- func (r *Image) Composite(overlay *Image, mode BlendMode, x, y int) error
- func (r *Image) Copy() (*Image, error)
- func (r *Image) Embed(left, top, width, height int, extend ExtendStrategy) error
- func (r *Image) EmbedBackground(left, top, width, height int, backgroundColor *Color) error
- func (r *Image) EmbedBackgroundRGBA(left, top, width, height int, backgroundColor *ColorRGBA) error
- func (r *Image) Exif() map[string]any
- func (r *Image) ExportAvif(params *AvifExportParams) ([]byte, error)
- func (r *Image) ExportGIF(params *GifExportParams) ([]byte, error)
- func (r *Image) ExportHeif(params *HeifExportParams) ([]byte, error)
- func (r *Image) ExportJp2k(params *Jp2kExportParams) ([]byte, error)
- func (r *Image) ExportJpeg(params *JpegExportParams) ([]byte, error)
- func (r *Image) ExportPng(params *PngExportParams) ([]byte, error)
- func (r *Image) ExportTiff(params *TiffExportParams) ([]byte, error)
- func (r *Image) ExportWebp(params *WebpExportParams) ([]byte, error)
- func (r *Image) ExtractArea(left, top, width, height int) error
- func (r *Image) FindTrim(threshold float64, x, y int) (int, int, int, int, error)
- func (r *Image) Flatten(backgroundColor *Color) error
- func (r *Image) Flip(direction Direction) error
- func (r *Image) Format() ImageType
- func (r *Image) GaussianBlur(sigma float64) error
- func (r *Image) GetPoint(x int, y int) ([]float64, error)
- func (r *Image) HasAlpha() bool
- func (r *Image) Height() int
- func (r *Image) Interpretation() Interpretation
- func (r *Image) Label(text, font string, x, y, size int, align Align, color *Color, opacity float64) error
- func (r *Image) Linear(a, b []float64) error
- func (r *Image) Modulate(brightness, saturation, hue float64) error
- func (r *Image) Orientation() int
- func (r *Image) PageHeight() int
- func (r *Image) Pages() int
- func (r *Image) RemoveExif() error
- func (r *Image) RemoveICCProfile() error
- func (r *Image) Replicate(across int, down int) error
- func (r *Image) Rotate(angle Angle) error
- func (r *Image) SetPageDelay(delay []int) error
- func (r *Image) SetPageHeight(height int) error
- func (r *Image) Sharpen(sigma float64, x1 float64, m2 float64) error
- func (r *Image) Thumbnail(width, height int, crop Interesting) error
- func (r *Image) ThumbnailWithSize(width, height int, crop Interesting, size Size) error
- func (r *Image) ToColorSpace(interpretation Interpretation) error
- func (r *Image) Width() int
- type ImageType
- type ImportParams
- type IntParam
- type Intent
- type Interesting
- type Interpretation
- type Jp2kExportParams
- type JpegExportParams
- type LogLevel
- type LoggingHandlerFunction
- type MemoryStats
- type Metadata
- type Option
- func WithConcurrency(num int) Option
- func WithDebug(debug bool) Option
- func WithDisableBlur(disabled bool) Option
- func WithDisableFilters(filters ...string) Option
- func WithFilter(name string, filter FilterFunc) Option
- func WithLogger(logger *zap.Logger) Option
- func WithMaxAnimationFrames(num int) Option
- func WithMaxCacheFiles(num int) Option
- func WithMaxCacheMem(num int) Option
- func WithMaxCacheSize(num int) Option
- func WithMaxFilterOps(num int) Option
- func WithMaxHeight(height int) Option
- func WithMaxResolution(res int) Option
- func WithMaxWidth(width int) Option
- func WithMozJPEG(enabled bool) Option
- type Param
- type PngExportParams
- type PngFilter
- type Processor
- func (v *Processor) CheckResolution(img *Image, err error) (*Image, error)
- func (v *Processor) FocalThumbnail(img *Image, w, h int, fx, fy float64) (err error)
- func (v *Processor) NewImage(ctx context.Context, blob *imagor.Blob, n, page int, dpi int) (*Image, error)
- func (v *Processor) NewThumbnail(ctx context.Context, blob *imagor.Blob, width, height int, crop Interesting, ...) (*Image, error)
- func (v *Processor) Process(ctx context.Context, blob *imagor.Blob, p imagorpath.Params, ...) (*imagor.Blob, error)
- func (v *Processor) Shutdown(_ context.Context) error
- func (v *Processor) Startup(_ context.Context) error
- func (v *Processor) Thumbnail(img *Image, width, height int, crop Interesting, size Size) error
- type Size
- type Source
- type SubsampleMode
- type TiffCompression
- type TiffExportParams
- type TiffPredictor
- type WebpExportParams
Constants ¶
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 ImageMimeTypes = map[ImageType]string{ ImageTypeGIF: "image/gif", ImageTypeJPEG: "image/jpeg", ImageTypePDF: "application/pdf", ImageTypePNG: "image/png", ImageTypeSVG: "image/svg+xml", ImageTypeTIFF: "image/tiff", ImageTypeWEBP: "image/webp", ImageTypeHEIF: "image/heif", ImageTypeBMP: "image/bmp", ImageTypeAVIF: "image/avif", ImageTypeJP2K: "image/jp2", }
ImageMimeTypes map the various image types to its mime type representation
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", ImageTypeAVIF: "avif", ImageTypeJP2K: "jp2k", }
ImageTypes defines the various image types supported by vips
Functions ¶
func IsAnimationSupported ¶
IsAnimationSupported indicates if image type supports animation
func IsLoadSupported ¶
IsLoadSupported indicates if image type supports load
func IsSaveSupported ¶
IsSaveSupported indicates if image type supports save
func ReadVipsMemStats ¶
func ReadVipsMemStats(stats *MemoryStats)
ReadVipsMemStats returns various memory statistics such as allocated memory and open files.
func SetLogging ¶
func SetLogging(handler LoggingHandlerFunction, verbosity LogLevel)
SetLogging set logging handler and verbosity
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
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 AvifExportParams ¶
AvifExportParams are options when exporting an AVIF to file or buffer.
func NewAvifExportParams ¶
func NewAvifExportParams() *AvifExportParams
NewAvifExportParams creates default values for an export of an AVIF image.
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 ColorRGBA ¶
type ColorRGBA struct {
R, G, B, A uint8
}
ColorRGBA represents an RGB with alpha channel (A)
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 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 FilterFunc ¶
type FilterFunc func(ctx context.Context, img *Image, load imagor.LoadFunc, args ...string) (err error)
FilterFunc filter handler function
type GifExportParams ¶
type GifExportParams struct { StripMetadata bool // 使用 quality 设置输出 GIF 的质量(1-100 之间的整数)。 Quality int // 使用 dither 设置 Floyd-Steinberg 抖动程度 Dither float64 // 使用 effort 控制 CPU 工作量(1 是最快,10 是最慢,7 是默认值)。 Effort int // 使用 bitdepth 设置输出 GIF 的位深度(1-8 之间的整数)。 Bitdepth int // 使用 interframe_maxerror 设置阈值,低于该阈值的像素被视为相等。帧与帧之间不发生变化的像素可以变得透明,从而提高压缩率。默认 0。 InterframeMaxerror int // 如果 reuse 为 TRUE,则 GIF 将使用从 in 中的元数据获取的单个全局调色板保存,并且不会进行新的调色板优化。 Reuse bool // 如果 interlace 为 TRUE,则 GIF 文件将为隔行扫描(逐行 GIF)。这些文件可能更适合通过慢速网络连接显示,但需要更多内存进行编码。 Interlace bool // 使用 interpalette_maxerror 设置阈值,低于该阈值将重用先前生成的调色板。 InterpaletteMaxerror int }
GifExportParams are options when exporting an GIF to file or buffer.
func NewGifExportParams ¶
func NewGifExportParams() *GifExportParams
NewGifExportParams creates default values for an export of a GIF image.
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 Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image contains a libvips image and manages its lifecycle.
func LoadImageFromBuffer ¶
func LoadImageFromBuffer(buf []byte, params *ImportParams) (*Image, error)
LoadImageFromBuffer loads an image buffer and creates a new Image
func LoadImageFromMemory ¶
LoadImageFromMemory loads a raw RGB/RGBA image buffer and creates a new Image
func LoadImageFromSource ¶
func LoadImageFromSource(s *Source, params *ImportParams) (*Image, error)
LoadImageFromSource loads a Source and creates a new Image
func LoadThumbnailFromSource ¶
func LoadThumbnailFromSource(s *Source, width, height int, crop Interesting, size Size, params *ImportParams) (*Image, error)
LoadThumbnailFromSource loads a Source and creates a new Image with thumbnail crop and resize
func (*Image) ColorSpace ¶
func (r *Image) ColorSpace() Interpretation
ColorSpace returns the interpretation of the current color space. Alias to Interpretation().
func (*Image) Composite ¶
Composite composites the given overlay image on top of the associated image with provided blending mode.
func (*Image) Embed ¶
func (r *Image) 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 (*Image) EmbedBackground ¶
EmbedBackground embeds the given picture with a background color
func (*Image) EmbedBackgroundRGBA ¶
EmbedBackgroundRGBA embeds the given picture with a background rgba color
func (*Image) ExportAvif ¶
func (r *Image) ExportAvif(params *AvifExportParams) ([]byte, error)
ExportAvif exports the image as AVIF to a buffer.
func (*Image) ExportGIF ¶
func (r *Image) ExportGIF(params *GifExportParams) ([]byte, error)
ExportGIF exports the image as GIF to a buffer.
func (*Image) ExportHeif ¶
func (r *Image) ExportHeif(params *HeifExportParams) ([]byte, error)
ExportHeif exports the image as HEIF to a buffer.
func (*Image) ExportJp2k ¶
func (r *Image) ExportJp2k(params *Jp2kExportParams) ([]byte, error)
ExportJp2k exports the image as JPEG2000 to a buffer.
func (*Image) ExportJpeg ¶
func (r *Image) ExportJpeg(params *JpegExportParams) ([]byte, error)
ExportJpeg exports the image as JPEG to a buffer.
func (*Image) ExportPng ¶
func (r *Image) ExportPng(params *PngExportParams) ([]byte, error)
ExportPng exports the image as PNG to a buffer.
func (*Image) ExportTiff ¶
func (r *Image) ExportTiff(params *TiffExportParams) ([]byte, error)
ExportTiff exports the image as TIFF to a buffer.
func (*Image) ExportWebp ¶
func (r *Image) ExportWebp(params *WebpExportParams) ([]byte, error)
ExportWebp exports the image as WEBP to a buffer.
func (*Image) ExtractArea ¶
ExtractArea crops the image to a specified area
func (*Image) FindTrim ¶
FindTrim returns the bounding box of the non-border part of the image Returned values are left, top, width, height
func (*Image) Flatten ¶
Flatten removes the alpha channel from the image and replaces it with the background color
func (*Image) GaussianBlur ¶
GaussianBlur blurs the image
func (*Image) GetPoint ¶
GetPoint reads a single pixel on an image. The pixel values are returned in a slice of length n.
func (*Image) Interpretation ¶
func (r *Image) Interpretation() Interpretation
Interpretation returns the current interpretation of the color space of the image.
func (*Image) Label ¶
func (r *Image) Label( text, font string, x, y, size int, align Align, color *Color, opacity float64, ) error
Label adds text label with font, dimensions, alignment, color and opacity
func (*Image) Linear ¶
Linear passes an image through a linear transformation (i.e. output = input * a + b). See https://libvips.github.io/libvips/API/current/libvips-arithmetic.html#vips-linear
func (*Image) Orientation ¶
Orientation returns the orientation number as it appears in the Exif, if present
func (*Image) PageHeight ¶
PageHeight return the height of a single page
func (*Image) Pages ¶
Pages returns the number of pages in the Image For animated images this corresponds to the number of frames
func (*Image) RemoveExif ¶
RemoveExif removes Exif metadata from the image.
func (*Image) 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 (*Image) SetPageDelay ¶
SetPageDelay set the page delay array for animation
func (*Image) SetPageHeight ¶
SetPageHeight set the height of a page For animated images this is used when "unrolling" back to frames
func (*Image) Sharpen ¶
Sharpen sharpens the image sigma: sigma of the gaussian x1: flat/jaggy threshold m2: slope for jaggy areas
func (*Image) Thumbnail ¶
func (r *Image) Thumbnail(width, height int, crop Interesting) error
Thumbnail resizes the image to the given width and height. crop decides algorithm vips uses to shrink and crop to fill target,
func (*Image) ThumbnailWithSize ¶
func (r *Image) ThumbnailWithSize(width, height int, crop Interesting, size Size) error
ThumbnailWithSize resizes the image to the given width and height. crop decides algorithm vips uses to shrink and crop to fill target, size controls upsize, downsize, both or force
func (*Image) ToColorSpace ¶
func (r *Image) ToColorSpace(interpretation Interpretation) error
ToColorSpace changes the color space of the image to the interpretation supplied as the parameter.
type ImportParams ¶
type ImportParams struct { AutoRotate BoolParam FailOnError BoolParam Page IntParam NumPages IntParam Density IntParam JpegShrinkFactor IntParam HeifThumbnail BoolParam SvgUnlimited BoolParam }
ImportParams are options for loading an image. Some are type-specific. For default loading, use NewImportParams() or specify nil
func NewImportParams ¶
func NewImportParams() *ImportParams
NewImportParams creates default ImportParams
func (*ImportParams) OptionString ¶
func (i *ImportParams) OptionString() string
OptionString convert import params to option_string
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 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 Jp2kExportParams ¶
type Jp2kExportParams struct { Quality int Lossless bool TileWidth int TileHeight int SubsampleMode SubsampleMode }
Jp2kExportParams are options when exporting an JPEG2000 to file or buffer.
func NewJp2kExportParams ¶
func NewJp2kExportParams() *Jp2kExportParams
NewJp2kExportParams creates default values for an export of an JPEG2000 image.
type JpegExportParams ¶
type JpegExportParams struct { StripMetadata bool Quality int Interlace bool OptimizeCoding bool SubsampleMode SubsampleMode TrellisQuant bool OvershootDeringing bool OptimizeScans bool QuantTable int }
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, vips creates interlaced JPEGs with a quality of 80/100.
type LogLevel ¶
type LogLevel int
LogLevel log level
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 )
LogLevel enum
type LoggingHandlerFunction ¶
LoggingHandlerFunction logging handler function
type MemoryStats ¶
MemoryStats is a data structure that houses various memory statistics from ReadVipsMemStats()
type Metadata ¶
type Metadata struct { Format string `json:"format"` ContentType string `json:"content_type"` Width int `json:"width"` Height int `json:"height"` Orientation int `json:"orientation"` Pages int `json:"pages"` Bands int `json:"bands"` Exif map[string]any `json:"exif"` }
Metadata image attributes
type Option ¶
type Option func(v *Processor)
Option Processor option
func WithConcurrency ¶
WithConcurrency with libvips concurrency option
func WithDisableBlur ¶
WithDisableBlur with disable blur option
func WithDisableFilters ¶
WithDisableFilters with disable filters option
func WithFilter ¶
func WithFilter(name string, filter FilterFunc) Option
WithFilter with filer option of name and FilterFunc pair
func WithMaxAnimationFrames ¶
WithMaxAnimationFrames with maximum count of animation frames option
func WithMaxCacheFiles ¶
WithMaxCacheFiles with libvips max cache files option
func WithMaxCacheMem ¶
WithMaxCacheMem with libvips max cache mem option
func WithMaxCacheSize ¶
WithMaxCacheSize with libvips max cache size option
func WithMaxFilterOps ¶
WithMaxFilterOps with maximum number of filter operations option
func WithMaxResolution ¶
WithMaxResolution with maximum resolution option
func WithMozJPEG ¶
WithMozJPEG with MozJPEG option. Require MozJPEG to be installed
type Param ¶
type Param struct {
// contains filtered or unexported fields
}
Param libvips options param
type PngExportParams ¶
type PngExportParams struct { StripMetadata bool Compression int Filter PngFilter Interlace bool Quality int Palette bool Dither float64 Bitdepth int Profile string // TODO: Use this param during save }
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, vips creates non-interlaced PNGs with a compression of 6/10.
type PngFilter ¶
type PngFilter int
PngFilter represents filter algorithms that can be applied before compression. See https://www.w3.org/TR/PNG-Filters.html
const ( PngFilterNone PngFilter = C.VIPS_FOREIGN_PNG_FILTER_NONE PngFilterSub PngFilter = C.VIPS_FOREIGN_PNG_FILTER_SUB PngFilterUo PngFilter = C.VIPS_FOREIGN_PNG_FILTER_UP PngFilterAvg PngFilter = C.VIPS_FOREIGN_PNG_FILTER_AVG PngFilterPaeth PngFilter = C.VIPS_FOREIGN_PNG_FILTER_PAETH PngFilterAll PngFilter = C.VIPS_FOREIGN_PNG_FILTER_ALL )
PngFilter enum
type Processor ¶
type Processor struct { Filters FilterMap DisableBlur bool DisableFilters []string MaxFilterOps int Logger *zap.Logger Concurrency int MaxCacheFiles int MaxCacheMem int MaxCacheSize int MaxWidth int MaxHeight int MaxResolution int MaxAnimationFrames int MozJPEG bool Debug bool // contains filtered or unexported fields }
Processor implements imagor.Processor interface
func (*Processor) CheckResolution ¶
CheckResolution check image resolution for image bomb prevention
func (*Processor) FocalThumbnail ¶
FocalThumbnail handles thumbnail with custom focal point
func (*Processor) NewImage ¶
func (v *Processor) NewImage(ctx context.Context, blob *imagor.Blob, n, page int, dpi int) (*Image, error)
NewImage creates new Image from imagor.Blob
func (*Processor) NewThumbnail ¶
func (v *Processor) NewThumbnail( ctx context.Context, blob *imagor.Blob, width, height int, crop Interesting, size Size, n, page int, dpi int, ) (*Image, error)
NewThumbnail creates new thumbnail with resize and crop from imagor.Blob
func (*Processor) Process ¶
func (v *Processor) Process( ctx context.Context, blob *imagor.Blob, p imagorpath.Params, load imagor.LoadFunc, ) (*imagor.Blob, error)
Process implements imagor.Processor interface
type Size ¶
type Size int
Size represents VipsSize type
const ( SizeBoth Size = C.VIPS_SIZE_BOTH SizeUp Size = C.VIPS_SIZE_UP SizeDown Size = C.VIPS_SIZE_DOWN SizeForce Size = C.VIPS_SIZE_FORCE SizeLast Size = C.VIPS_SIZE_LAST )
Size enum
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source contains a libvips VipsSourceCustom and manages its lifecycle.
func (*Source) LoadImage ¶
func (s *Source) LoadImage(params *ImportParams) (*Image, error)
LoadImage creates a new Image from source
func (*Source) LoadThumbnail ¶
func (s *Source) LoadThumbnail(width, height int, crop Interesting, size Size, params *ImportParams) (*Image, error)
LoadThumbnail creates a new Image with thumbnail crop and resize from source
type SubsampleMode ¶
type SubsampleMode int
SubsampleMode correlates to a libvips subsample mode
const ( VipsForeignSubsampleAuto SubsampleMode = C.VIPS_FOREIGN_JPEG_SUBSAMPLE_AUTO VipsForeignSubsampleOn SubsampleMode = C.VIPS_FOREIGN_JPEG_SUBSAMPLE_ON VipsForeignSubsampleOff SubsampleMode = C.VIPS_FOREIGN_JPEG_SUBSAMPLE_OFF VipsForeignSubsampleLast SubsampleMode = C.VIPS_FOREIGN_JPEG_SUBSAMPLE_LAST )
SubsampleMode enum correlating to libvips subsample modes
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, vips creates lossy images with a quality of 75/100.