vipsprocessor

package
v1.5.8 Latest Latest

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

Go to latest
Published: Jun 2, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Image for: Documentation ¶

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAnimationSupported added in v1.5.0

func IsAnimationSupported(imageType vips.ImageType) bool

IsAnimationSupported indicates if image type supports animation

func WrapErr added in v1.5.0

func WrapErr(err error) error

WrapErr wraps error to become imagor.Error

Types

type FallbackFunc added in v1.5.5

type FallbackFunc func(blob *imagor.Blob, options *vips.LoadOptions) (*vips.Image, error)

FallbackFunc vips.Image fallback handler when vips.NewImageFromSource failed

type FilterFunc

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

FilterFunc filter handler function

type FilterMap

type FilterMap map[string]FilterFunc

FilterMap filter handler map

type Metadata added in v1.5.0

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]string `json:"exif"`
}

Metadata image attributes

type Option

type Option func(v *Processor)

Option Processor option

func WithAvifSpeed added in v1.5.0

func WithAvifSpeed(avifSpeed int) Option

WithAvifSpeed with avif speed option

func WithConcurrency added in v0.2.11

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 WithForceBmpFallback added in v1.5.5

func WithForceBmpFallback() Option

WithForceBmpFallback force with BMP fallback

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger with logger option

func WithMaxAnimationFrames added in v0.8.0

func WithMaxAnimationFrames(num int) Option

WithMaxAnimationFrames with maximum count of animation frames option

func WithMaxCacheFiles added in v0.2.9

func WithMaxCacheFiles(num int) Option

WithMaxCacheFiles with libvips max cache files option

func WithMaxCacheMem added in v0.2.9

func WithMaxCacheMem(num int) Option

WithMaxCacheMem with libvips max cache mem option

func WithMaxCacheSize added in v0.2.9

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 added in v0.5.0

func WithMaxHeight(height int) Option

WithMaxHeight with maximum height option

func WithMaxResolution added in v0.9.12

func WithMaxResolution(res int) Option

WithMaxResolution with maximum resolution option

func WithMaxWidth added in v0.5.0

func WithMaxWidth(width int) Option

WithMaxWidth with maximum width option

func WithMozJPEG added in v0.8.7

func WithMozJPEG(enabled bool) Option

WithMozJPEG with MozJPEG option. Require MozJPEG to be installed

func WithStripMetadata added in v1.5.0

func WithStripMetadata(enabled bool) Option

WithStripMetadata with strip all metadata from image option

func WithUnlimited added in v1.5.5

func WithUnlimited(unlimited bool) Option

WithUnlimited with unlimited option that remove all denial of service limits

type Processor added in v1.5.0

type Processor struct {
	Filters            FilterMap
	FallbackFunc       FallbackFunc
	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
	StripMetadata      bool
	AvifSpeed          int
	Unlimited          bool
	Debug              bool
	// contains filtered or unexported fields
}

Processor implements imagor.Processor interface

func NewProcessor added in v1.5.0

func NewProcessor(options ...Option) *Processor

NewProcessor create Processor

func (*Processor) CheckResolution added in v1.5.0

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

CheckResolution check image resolution for image bomb prevention

func (*Processor) FocalThumbnail added in v1.5.0

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

FocalThumbnail handles thumbnail with custom focal point

func (*Processor) NewImage added in v1.5.0

func (v *Processor) NewImage(ctx context.Context, blob *imagor.Blob, n, page int, dpi int) (*vips.Image, error)

NewImage creates new Image from imagor.Blob

func (*Processor) NewThumbnail added in v1.5.0

func (v *Processor) NewThumbnail(
	ctx context.Context, blob *imagor.Blob, width, height int, crop vips.Interesting,
	size vips.Size, n, page int, dpi int,
) (*vips.Image, error)

NewThumbnail creates new thumbnail with resize and crop from imagor.Blob

func (*Processor) Process added in v1.5.0

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 added in v1.5.0

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

Shutdown implements imagor.Processor interface

func (*Processor) Startup added in v1.5.0

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

Startup implements imagor.Processor interface

func (*Processor) Thumbnail added in v1.5.0

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

Thumbnail handles thumbnail operation