vips

package
v1.4.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const MajorVersion = int(C.VIPS_MAJOR_VERSION)

MajorVersion is the libvips major component of the version string (x in x.y.z)

View Source
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

View Source
const MinorVersion = int(C.VIPS_MINOR_VERSION)

MinorVersion is the libvips minor component of the version string (y in x.y.z)

View Source
const Version = string(C.VIPS_VERSION)

Version is the full libvips version string (x.y.z)

Variables

View Source
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

View Source
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

func IsAnimationSupported(imageType ImageType) bool

IsAnimationSupported indicates if image type supports animation

func IsLoadSupported

func IsLoadSupported(imageType ImageType) bool

IsLoadSupported indicates if image type supports load

func IsSaveSupported

func IsSaveSupported(imageType ImageType) bool

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

func Shutdown

func Shutdown()

Shutdown libvips

func Startup

func Startup(config *Config)

Startup sets up the libvips support and ensures the versions are correct. Pass in nil for default configuration.

func WrapErr

func WrapErr(err error) error

WrapErr wraps error to become imagor.Error

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

type AvifExportParams struct {
	StripMetadata bool
	Quality       int
	Lossless      bool
	Speed         int
}

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

Constants define the various Porter-Duff and PDF blend modes. See https://libvips.github.io/libvips/API/current/libvips-conversion.html#VipsBlendMode

type BoolParam

type BoolParam struct {
	Param
}

BoolParam bool param

func (*BoolParam) Get

func (p *BoolParam) Get() bool

Get bool param

func (*BoolParam) Set

func (p *BoolParam) Set(v bool)

Set bool param

type Color

type Color struct {
	R, G, B uint8
}

Color represents an RGB

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
	VectorEnabled    bool
}

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

ExtendStrategy enum

type FilterFunc

type FilterFunc func(ctx context.Context, img *Image, load imagor.LoadFunc, args ...string) (err error)

FilterFunc filter handler function

type FilterMap

type FilterMap map[string]FilterFunc

FilterMap filter handler map

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

type HeifExportParams struct {
	Quality  int
	Lossless bool
}

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

func LoadImageFromMemory(buf []byte, width, height, bands int) (*Image, error)

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) AddAlpha

func (r *Image) AddAlpha() error

AddAlpha adds an alpha channel to the associated image.

func (*Image) Bands

func (r *Image) Bands() int

Bands returns the number of bands for this image.

func (*Image) Close

func (r *Image) Close()

Close closes the image and frees the memory

func (*Image) ColorSpace

func (r *Image) ColorSpace() Interpretation

ColorSpace returns the interpretation of the current color space. Alias to Interpretation().

func (*Image) Composite

func (r *Image) Composite(overlay *Image, mode BlendMode, x, y int) error

Composite composites the given overlay image on top of the associated image with provided blending mode.

func (*Image) Copy

func (r *Image) Copy() (*Image, error)

Copy creates a new copy of the given image.

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

func (r *Image) EmbedBackground(left, top, width, height int, backgroundColor *Color) error

EmbedBackground embeds the given picture with a background color

func (*Image) EmbedBackgroundRGBA

func (r *Image) EmbedBackgroundRGBA(left, top, width, height int, backgroundColor *ColorRGBA) error

EmbedBackgroundRGBA embeds the given picture with a background rgba color

func (*Image) Exif

func (r *Image) Exif() map[string]any

Exif extracts Exif key value data

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

func (r *Image) ExtractArea(left, top, width, height int) error

ExtractArea crops the image to a specified area

func (*Image) FindTrim

func (r *Image) FindTrim(threshold float64, x, y int) (int, int, int, int, error)

FindTrim returns the bounding box of the non-border part of the image Returned values are left, top, width, height

func (*Image) Flatten

func (r *Image) Flatten(backgroundColor *Color) error

Flatten removes the alpha channel from the image and replaces it with the background color

func (*Image) Flip

func (r *Image) Flip(direction Direction) error

Flip flips the image either horizontally or vertically based on the parameter

func (*Image) Format

func (r *Image) Format() ImageType

Format returns the initial format of the vips image when loaded.

func (*Image) GaussianBlur

func (r *Image) GaussianBlur(sigma float64) error

GaussianBlur blurs the image

func (*Image) GetPoint

func (r *Image) GetPoint(x int, y int) ([]float64, error)

GetPoint reads a single pixel on an image. The pixel values are returned in a slice of length n.

func (*Image) HasAlpha

func (r *Image) HasAlpha() bool

HasAlpha returns if the image has an alpha layer.

func (*Image) Height

func (r *Image) Height() int

Height returns the height of this image.

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

func (r *Image) Linear(a, b []float64) error

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) Modulate

func (r *Image) Modulate(brightness, saturation, hue float64) error

Modulate the colors

func (*Image) Orientation

func (r *Image) Orientation() int

Orientation returns the orientation number as it appears in the Exif, if present

func (*Image) PageHeight

func (r *Image) PageHeight() int

PageHeight return the height of a single page

func (*Image) Pages

func (r *Image) Pages() int

Pages returns the number of pages in the Image For animated images this corresponds to the number of frames

func (*Image) RemoveExif

func (r *Image) RemoveExif() error

RemoveExif removes Exif metadata from the image.

func (*Image) RemoveICCProfile

func (r *Image) RemoveICCProfile() error

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) Replicate

func (r *Image) Replicate(across int, down int) error

Replicate repeats an image many times across and down

func (*Image) Rotate

func (r *Image) Rotate(angle Angle) error

Rotate rotates the image by multiples of 90 degrees

func (*Image) SetPageDelay

func (r *Image) SetPageDelay(delay []int) error

SetPageDelay set the page delay array for animation

func (*Image) SetPageHeight

func (r *Image) SetPageHeight(height int) error

SetPageHeight set the height of a page For animated images this is used when "unrolling" back to frames

func (*Image) Sharpen

func (r *Image) Sharpen(sigma float64, x1 float64, m2 float64) error

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.

func (*Image) Width

func (r *Image) Width() int

Width returns the width of this image.

type ImageType

type ImageType int

ImageType represents an image type

const (
	ImageTypeUnknown ImageType = iota
	ImageTypeGIF
	ImageTypeJPEG
	ImageTypeMagick
	ImageTypePDF
	ImageTypePNG
	ImageTypeSVG
	ImageTypeTIFF
	ImageTypeWEBP
	ImageTypeHEIF
	ImageTypeBMP
	ImageTypeAVIF
	ImageTypeJP2K
)

ImageType enum

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 IntParam

type IntParam struct {
	Param
}

IntParam int param

func (*IntParam) Get

func (p *IntParam) Get() int

Get int param

func (*IntParam) Set

func (p *IntParam) Set(v int)

Set int param

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

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

type LoggingHandlerFunction func(messageDomain string, messageLevel LogLevel, message string)

LoggingHandlerFunction logging handler function

type MemoryStats

type MemoryStats struct {
	Mem     int64
	MemHigh int64
	Files   int64
	Allocs  int64
}

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

func WithConcurrency(num int) Option

WithConcurrency with libvips concurrency option

func WithDebug

func WithDebug(debug bool) Option

WithDebug with debug option

func WithDisableBlur

func WithDisableBlur(disabled bool) Option

WithDisableBlur with disable blur option

func WithDisableFilters

func WithDisableFilters(filters ...string) Option

WithDisableFilters with disable filters option

func WithFilter

func WithFilter(name string, filter FilterFunc) Option

WithFilter with filer option of name and FilterFunc pair

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger with logger option

func WithMaxAnimationFrames

func WithMaxAnimationFrames(num int) Option

WithMaxAnimationFrames with maximum count of animation frames option

func WithMaxCacheFiles

func WithMaxCacheFiles(num int) Option

WithMaxCacheFiles with libvips max cache files option

func WithMaxCacheMem

func WithMaxCacheMem(num int) Option

WithMaxCacheMem with libvips max cache mem option

func WithMaxCacheSize

func WithMaxCacheSize(num int) Option

WithMaxCacheSize with libvips max cache size option

func WithMaxFilterOps

func WithMaxFilterOps(num int) Option

WithMaxFilterOps with maximum number of filter operations option

func WithMaxHeight

func WithMaxHeight(height int) Option

WithMaxHeight with maximum height option

func WithMaxResolution

func WithMaxResolution(res int) Option

WithMaxResolution with maximum resolution option

func WithMaxWidth

func WithMaxWidth(width int) Option

WithMaxWidth with maximum width option

func WithMozJPEG

func WithMozJPEG(enabled bool) Option

WithMozJPEG with MozJPEG option. Require MozJPEG to be installed

type Param

type Param struct {
	// contains filtered or unexported fields
}

Param libvips options param

func (*Param) IsSet

func (p *Param) IsSet() bool

IsSet is param set

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

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 NewProcessor

func NewProcessor(options ...Option) *Processor

NewProcessor create Processor

func (*Processor) CheckResolution

func (v *Processor) CheckResolution(img *Image, err error) (*Image, error)

CheckResolution check image resolution for image bomb prevention

func (*Processor) FocalThumbnail

func (v *Processor) FocalThumbnail(img *Image, w, h int, fx, fy float64) (err error)

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

func (*Processor) Shutdown

func (v *Processor) Shutdown(_ context.Context) error

Shutdown implements imagor.Processor interface

func (*Processor) Startup

func (v *Processor) Startup(_ context.Context) error

Startup implements imagor.Processor interface

func (*Processor) Thumbnail

func (v *Processor) Thumbnail(
	img *Image, width, height int, crop Interesting, size Size,
) error

Thumbnail handles thumbnail operation

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 NewSource

func NewSource(reader io.ReadCloser) *Source

NewSource creates Source from reader

func (*Source) Close

func (s *Source) Close()

Close source

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

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

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL