Documentation ¶
Index ¶
- Constants
- Variables
- type Dummy
- type ImageInfo
- type ImageMagick
- func (p *ImageMagick) FitToSize(data []byte, size string, imgId string, supportedFormats []string) (*img.Image, error)
- func (p *ImageMagick) Optimise(data []byte, imgId string, supportedFormats []string) (*img.Image, error)
- func (p *ImageMagick) Resize(data []byte, size string, imgId string, supportedFormats []string) (*img.Image, error)
Constants ¶
const ( MaxWebpWidth = 16383 MaxWebpHeight = 16383 )
Variables ¶
var Debug bool = true
If set then will print all commands to stdout.
Functions ¶
This section is empty.
Types ¶
type Dummy ¶
type Dummy struct{}
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) 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.