image

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtensionToType

func ExtensionToType(name string) bimg.ImageType

ExtensionToType returns the image type based on the given image type alias.

func ExtractImageTypeFromMime

func ExtractImageTypeFromMime(mime string) string

ExtractImageTypeFromMime returns the MIME image type.

func GetImageMimeType

func GetImageMimeType(code bimg.ImageType) string

GetImageMimeType returns the MIME type based on the given image type code.

func IsFormatSupported

func IsFormatSupported(format string) bool

IsFormatSupported returns true if the image format is supported by bimg.

func IsImageMimeTypeSupported

func IsImageMimeTypeSupported(mime string) bool

IsImageMimeTypeSupported returns true if the image MIME type is supported by bimg.

Types

type CropType

type CropType struct {
	Width  int
	Height int
	X      int
	Y      int
}

CropType struct

type FilterType

type FilterType int

FilterType type

const (
	FilterGreyscale FilterType = iota
	FilterSepia
)

Filter

type FitType

type FitType int

FitType type

const (
	FitContain FitType = iota
	FitMax
	FitFill
	FitStretch
	FitCropTopLeft
	FitCropTop
	FitCropTopRight
	FitCropLeft
	FitCropCenter
	FitCropRight
	FitCropBottomLeft
	FitCropBottom
	FitCropBottomRight
	FitCropFocalPoint
)

Fit

type Image

type Image struct {
	Body []byte
	Mime string
}

Image stores an image binary buffer and its MIME type

type MockProcessor

type MockProcessor struct {
	mock.Mock
}

MockProcessor is an autogenerated mock type for the Processor type

func (*MockProcessor) ProcessImage

func (_m *MockProcessor) ProcessImage(resource *Resource) error

ProcessImage provides a mock function with given fields: resource

type OptionParser

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

OptionParser struct

func NewOptionParser

func NewOptionParser() *OptionParser

NewOptionParser func

func (OptionParser) Parse

func (p OptionParser) Parse(r *http.Request) (*Options, error)

Parse Option from url

type Options

type Options struct {
	Orientation bimg.Angle     `schema:"or"`
	Crop        CropType       `schema:"crop"`
	Width       int            `schema:"w"`
	Height      int            `schema:"h"`
	Fit         FitType        `schema:"fit"`
	DPR         float64        `schema:"dpr"`
	Brightness  int            `schema:"bri"`
	Contrast    int            `schema:"con"`
	Gamma       float64        `schema:"gam"`
	Sharpen     int            `schema:"sharp"`
	Blur        int            `schema:"blur"`
	Filter      FilterType     `schema:"-"`
	Background  []uint8        `schema:"bg"`
	Quality     int            `schema:"q"`
	Format      bimg.ImageType `schema:"fm"`
	Compression int            `schema:"-"`
	// contains filtered or unexported fields
}

Options represent all the supported image transformation params as first level members

func (*Options) Hash

func (o *Options) Hash() string

Hash return hash of options

func (Options) ToBimg

func (o Options) ToBimg() bimg.Options

ToBimg creates a new bimg compatible options struct mapping the fields properly

type Processor

type Processor interface {
	ProcessImage(resource *Resource) error
}

Processor interface

func NewProcessor

func NewProcessor() Processor

NewProcessor constructor

type Resource

type Resource struct {
	Name       string
	Path       string
	Options    *Options
	MimeType   string
	ModifiedAt time.Time
	Body       []byte
	Size       int
}

Resource struct

Jump to

Keyboard shortcuts

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