resizer

package
v0.0.0-...-7e8a30b Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AUTO_CROP = iota
	NORMAL_RESIZE
	ORIGINAL
)
View Source
const (
	GEO_NONE = iota
	GEO_WIDTH
	GEO_HEIGHT
	GEO_QUALITY
	GEO_AUTO_CROP
	GEO_MANUAL_CROP
	GEO_WIDTH_OFFSET
	GEO_HEIGHT_OFFSET
	GEO_CROP_WIDTH
	GEO_CROP_HEIGHT
	GEO_ASSUMPTION_WIDTH
	GEO_ORIGINAL
	GEO_MIDDLE
)
View Source
const (
	DEFAULT_QUALITY = 70
)
View Source
const GEOMETRY_DEFAULT_QUALITY = 80
View Source
const GEOMETRY_MAX_QUALITY = 100
View Source
const GEOMETRY_MIN_QUALITY = 0

Variables

View Source
var (
	IsWorkerMode bool

	ResizeWorkerSize          int
	ResizeWorkerWaitBufferNum int

	ErrTooManyRunningResizeWorker = errors.New("Too many running resize worker error.")
)
View Source
var (
	MiddleImageSizes = []string{"original", "1000", "2000", "3000"}
)

Functions

func CanResizeRequest

func CanResizeRequest() bool

func RequestPayloadLen

func RequestPayloadLen() int

func Run

func Run(image []byte, option *ResizeOption) (resizedImage []byte, err error)

Types

type Coodinates

type Coodinates struct {
	ResizeWidth, ResizeHeight int
	CropWidth, CropHeight     int
	WidthOffset, HeightOffset int
}

func (*Coodinates) CanCrop

func (c *Coodinates) CanCrop() bool

func (*Coodinates) ToString

func (c *Coodinates) ToString() string

func (*Coodinates) Valid

func (c *Coodinates) Valid() bool

type CoodinatesCalculator

type CoodinatesCalculator struct {
	ImageWidth  int
	ImageHeight int
	Width       int
	Height      int
}

func NewCoodinatesCalculator

func NewCoodinatesCalculator(option *ResizeOption) (*CoodinatesCalculator, error)

func (*CoodinatesCalculator) AutoCrop

func (c *CoodinatesCalculator) AutoCrop() (coodinates *Coodinates)

func (*CoodinatesCalculator) Calc

func (c *CoodinatesCalculator) Calc(option *ResizeOption) (coodinates *Coodinates)

func (*CoodinatesCalculator) ManualCrop

func (c *CoodinatesCalculator) ManualCrop(option *ResizeOption) (coodinates *Coodinates)

func (*CoodinatesCalculator) Resize

func (c *CoodinatesCalculator) Resize() (coodinates *Coodinates)

func (*CoodinatesCalculator) SetImageSize

func (c *CoodinatesCalculator) SetImageSize(width int, height int)

type ErrInvalidGeometry

type ErrInvalidGeometry struct {
	Message string
	// contains filtered or unexported fields
}

func (*ErrInvalidGeometry) Error

func (e *ErrInvalidGeometry) Error() string

type ErrInvalidGeometryOrderRequest

type ErrInvalidGeometryOrderRequest struct {
	Message string
	// contains filtered or unexported fields
}

type ErrInvalidOption

type ErrInvalidOption struct {
	Message string
	// contains filtered or unexported fields
}

func (*ErrInvalidOption) Error

func (e *ErrInvalidOption) Error() string

type Geometry

type Geometry struct {
	Width              int    `json:"width"`
	Height             int    `json:"height"`
	Quality            int    `json:"quality"`
	NeedsAutoCrop      bool   `json:"needs_auto_crop"`
	NeedsManualCrop    bool   `json:"needs_manual_crop"`
	CropWidthOffset    int    `json:"cropWidthOffset"`
	CropHeightOffset   int    `json:"cropHeightOffset"`
	CropWidth          int    `json:"cropWidth"`
	CropHeight         int    `json:"cropHeight"`
	AssumptionWidth    int    `json:"assumptionWidth"`
	NeedsOriginalImage bool   `json:"needs_original_image"`
	MiddleImageSize    string `json:"middle_image_size"`
}

func ParseGeometry

func ParseGeometry(geo string) (*Geometry, error)

func (*Geometry) ResizeMode

func (g *Geometry) ResizeMode() int

func (*Geometry) ToResizeOption

func (g *Geometry) ToResizeOption() (resizeOption *ResizeOption)

func (*Geometry) ToString

func (g *Geometry) ToString() string

type ResizeOption

type ResizeOption struct {
	Width            int
	Height           int
	NeedsAutoCrop    bool
	NeedsManualCrop  bool
	CropWidthOffset  int
	CropHeightOffset int
	CropWidth        int
	CropHeight       int
	AssumptionWidth  int
	Quality          int

	SizeHintWidth  int
	SizeHintHeight int

	SourceContentType string
	Format            string
}

func (*ResizeOption) HasAlphaChannel

func (o *ResizeOption) HasAlphaChannel() bool

func (*ResizeOption) HasSizeHint

func (o *ResizeOption) HasSizeHint() bool

func (*ResizeOption) NeedsRemoveAlpha

func (o *ResizeOption) NeedsRemoveAlpha() bool

type ResizeRequest

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

type ResizeResult

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

func Resize

func Resize(image []byte, option *ResizeOption) (result *ResizeResult)

Jump to

Keyboard shortcuts

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