engine

package
v0.0.0-...-56fb55f Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2017 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContentTypes = map[string]string{
	"jpeg": "image/jpeg",
	"jpg":  "image/jpeg",
	"png":  "image/png",
	"bmp":  "image/bmp",
	"gif":  "image/gif",
}
View Source
var Fit = &Operation{
	"fit",
}
View Source
var Flip = &Operation{
	"flip",
}
View Source
var FlipTransformations = map[string]ImageTransformation{
	"h": imaging.FlipH,
	"v": imaging.FlipV,
}
View Source
var Formats = map[string]imaging.Format{
	"jpeg": imaging.JPEG,
	"jpg":  imaging.JPEG,
	"png":  imaging.PNG,
	"gif":  imaging.GIF,
	"bmp":  imaging.BMP,
}
View Source
var Noop = &Operation{
	"noop",
}
View Source
var Operations = map[string]*Operation{
	Resize.Name:    Resize,
	Thumbnail.Name: Thumbnail,
	Flip.Name:      Flip,
	Rotate.Name:    Rotate,
	Fit.Name:       Fit,
	Noop.Name:      Noop,
}
View Source
var Resize = &Operation{
	"resize",
}
View Source
var Rotate = &Operation{
	"rotate",
}
View Source
var RotateTransformations = map[int]ImageTransformation{
	90:  imaging.Rotate90,
	270: imaging.Rotate270,
	180: imaging.Rotate180,
}
View Source
var Thumbnail = &Operation{
	"thumbnail",
}

Functions

func NewContext

func NewContext(ctx context.Context, e Engine) context.Context

NewContext instantiate a new context with an engine

func ToContext

func ToContext(c Setter, e Engine)

ToContext adds the Managers to this context if it supports the Setter interface.

Types

type Engine

type Engine interface {
	Resize(img *image.ImageFile, width int, height int, options *Options) ([]byte, error)
	Thumbnail(img *image.ImageFile, width int, height int, options *Options) ([]byte, error)
	Transform(img *image.ImageFile, operation *Operation, qs map[string]string) (*image.ImageFile, error)
	Flip(img *image.ImageFile, pos string, options *Options) ([]byte, error)
	Rotate(img *image.ImageFile, deg int, options *Options) ([]byte, error)
	Fit(img *image.ImageFile, width int, height int, options *Options) ([]byte, error)
}

func FromContext

func FromContext(c context.Context) Engine

FromContext returns the engine associated with this context.

type GoImageEngine

type GoImageEngine struct {
	DefaultFormat  string
	Format         string
	DefaultQuality int
}

func (*GoImageEngine) Fit

func (e *GoImageEngine) Fit(img *imagefile.ImageFile, width int, height int, options *Options) ([]byte, error)

func (*GoImageEngine) Flip

func (e *GoImageEngine) Flip(img *imagefile.ImageFile, pos string, options *Options) ([]byte, error)

func (*GoImageEngine) Resize

func (e *GoImageEngine) Resize(img *imagefile.ImageFile, width int, height int, options *Options) ([]byte, error)

func (*GoImageEngine) Rotate

func (e *GoImageEngine) Rotate(img *imagefile.ImageFile, deg int, options *Options) ([]byte, error)

func (*GoImageEngine) Scale

func (e *GoImageEngine) Scale(img image.Image, dstWidth int, dstHeight int, upscale bool, trans Transformation) image.Image

func (*GoImageEngine) Source

func (e *GoImageEngine) Source(img *imagefile.ImageFile) (image.Image, error)

func (*GoImageEngine) Thumbnail

func (e *GoImageEngine) Thumbnail(img *imagefile.ImageFile, width int, height int, options *Options) ([]byte, error)

func (*GoImageEngine) ToBytes

func (e *GoImageEngine) ToBytes(img image.Image, format imaging.Format, quality int) ([]byte, error)

func (*GoImageEngine) Transform

func (e *GoImageEngine) Transform(img *imagefile.ImageFile, operation *Operation, qs map[string]string) (*imagefile.ImageFile, error)

func (*GoImageEngine) TransformGIF

func (e *GoImageEngine) TransformGIF(img *imagefile.ImageFile, width int, height int, options *Options, trans Transformation) ([]byte, error)

type ImageTransformation

type ImageTransformation func(img image.Image) *image.NRGBA

type Operation

type Operation struct {
	Name string
}

type Options

type Options struct {
	Upscale bool
	Format  imaging.Format
	Quality int
}

type Setter

type Setter interface {
	Set(string, interface{})
}

Setter defines a context that enables setting values.

type Transformation

type Transformation func(img image.Image, width int, height int, filter imaging.ResampleFilter) *image.NRGBA

Jump to

Keyboard shortcuts

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