processor

package
v6.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxWebpWidth  = 16383
	MaxWebpHeight = 16383

	// There are two aspects to this:
	// * Encoding to AVIF consumes a lot of memory
	// * On big sizes quality of Webp is better (could be a codec thing rather than a format)
	MaxAVIFTargetSize = 1000 * 1000
)

Variables

View Source
var Debug bool = true

If set then will print all commands to stdout.

Functions

This section is empty.

Types

type ImageMagick

type ImageMagick struct {

	// AdditionalArgs are static arguments that will be passed to ImageMagick "convert" command for all operations.
	// Argument name and value should be in separate array elements.
	AdditionalArgs []string
	// GetAdditionalArgs could return additional argument to ImageMagick "convert" command.
	// "op" is the name of the operation: "optimise", "resize" or "fit".
	// Argument name and value should be in separate array elements.
	GetAdditionalArgs func(op string, image []byte, imageInfo *img.Info) []string
	// contains filtered or unexported fields
}

func NewImageMagick

func NewImageMagick(im string, idi string) (*ImageMagick, error)

NewImageMagick creates a new ImageMagick processor. It does require ImageMagick binaries to be installed on the local machine.

im is a path to ImageMagick "convert" binary. idi is a path to ImageMagick "identify" binary.

func (*ImageMagick) FitToSize

func (p *ImageMagick) FitToSize(data []byte, size string, imgId string, supportedFormats []string) (*img.Image, error)

FitToSize resizes input image to exact size with cropping everything that out of the bound. It doesn't respect the aspect ratio of the original image.

Format of the size argument is WIDTHxHEIGHT, e.g. 300x200. Both dimensions must be included.

func (*ImageMagick) Optimise

func (p *ImageMagick) Optimise(data []byte, imgId string, supportedFormats []string) (*img.Image, error)

func (*ImageMagick) Resize

func (p *ImageMagick) Resize(data []byte, size string, imgId string, supportedFormats []string) (*img.Image, error)

Resize resizes an image to the given size preserving aspect ratio. No cropping applies.

Format of the size argument is WIDTHxHEIGHT with any of the dimension could be dropped, e.g. 300, x200, 300x200.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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