processor

package
v5.0.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2020 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MaxWebpWidth  = 16383
	MaxWebpHeight = 16383
)

Variables

View Source
var Debug bool = true

If set then will print all commands to stdout.

Functions

This section is empty.

Types

type Dummy

type Dummy struct{}

func (*Dummy) FitToSize

func (p *Dummy) FitToSize(data []byte, size string, imgId string) ([]byte, error)

Returns original data

func (*Dummy) Optimise

func (p *Dummy) Optimise(data []byte, imgId string, supportedFormats []string) ([]byte, error)

Returns original data

func (*Dummy) Resize

func (p *Dummy) Resize(data []byte, size string, imgId string) ([]byte, error)

Returns original data

type ImageInfo

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

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 *ImageInfo) []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.

Jump to

Keyboard shortcuts

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