vipsutil

package
v0.0.0-...-f5bec2b Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoopResizeResult = ResizeResult{
	Scale: 1.0,
}

Functions

func LibvipsInit

func LibvipsInit()

LibvipsInit calls vips_init, and then vips_cache_set_max, etc to make libvips available for use. The counterpart LibvipsShutdown is intentionally not exposed because libvips does not support restart. After vips_shutdown has been called, libvips can no longer be used again in the program.

Types

type Daemon

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

func OpenDaemon

func OpenDaemon(numWorker int) *Daemon

func (*Daemon) Close

func (v *Daemon) Close() error

func (*Daemon) Process

func (v *Daemon) Process(i Input) (*Output, error)

type ImageDimensions

type ImageDimensions struct {
	// Width is the width of the source image.
	Width int
	// Height is the height of the source image.
	Height int
}

ImageDimensions is the dimensions of the source image.

type Input

type Input struct {
	Reader  io.Reader
	Options Options
}

type Options

type Options struct {
	Width            int
	Height           int
	ResizingModeType ResizingModeType
}

func (Options) ShouldResize

func (o Options) ShouldResize() bool

type Output

type Output struct {
	FileExtension string
	Data          []byte
}

type ResizeDimensions

type ResizeDimensions struct {
	// Width is the maximum width of the resulting image.
	Width int
	// Height is the maximum height of the resulting image.
	Height int
}

ResizeDimensions is the input parameters of the resize operation.

type ResizeResult

type ResizeResult struct {
	// Scale is the scale of the resulting image.
	// If it is 1, then scaling is not performed.
	Scale float64
	// Crop is necessary sometimes if the aspect ratios do not match.
	Crop *image.Rectangle
}

ResizeResult is the result of the resize operation.

type ResizingMode

type ResizingMode interface {
	Resize(image ImageDimensions, resize ResizeDimensions) ResizeResult
}

ResizingMode is the abstraction of different resizing flavors.

func ResizingModeFromType

func ResizingModeFromType(t ResizingModeType) ResizingMode

type ResizingModeContain

type ResizingModeContain struct{}

func (ResizingModeContain) Resize

type ResizingModeCover

type ResizingModeCover struct{}

func (ResizingModeCover) Resize

type ResizingModeScaleDown

type ResizingModeScaleDown struct{}

ResizingModeScaleDown shrink the image so that the resulting image is fully fit within ResizeDimensions.

func (ResizingModeScaleDown) Resize

type ResizingModeType

type ResizingModeType string
const (
	ResizingModeTypeScaleDown ResizingModeType = "scale-down"
	ResizingModeTypeContain   ResizingModeType = "contain"
	ResizingModeTypeCover     ResizingModeType = "cover"
)

Jump to

Keyboard shortcuts

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