optimizer

package
v0.0.0-...-a04687a Latest Latest
Warning

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

Go to latest
Published: May 16, 2017 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPool = NewTaskPool()

Functions

func CanOptimize

func CanOptimize(optimizers []ImageOptimizer, mimeType string, acceptedTyped []string) bool

Types

type AutomaticOptimizer

type AutomaticOptimizer struct {
	Optimizer ImageQualityOptimizer
	MinSsim   float64
}

func (*AutomaticOptimizer) CanOptimize

func (o *AutomaticOptimizer) CanOptimize(mimeType string, acceptedTypes []string) bool

func (*AutomaticOptimizer) Optimize

func (o *AutomaticOptimizer) Optimize(ctx context.Context, sourcePath string, hidpi bool) (*ImageDescription, error)

type ImageDescription

type ImageDescription struct {
	Optimizer Name
	Path      string
	MimeType  string
	Size      int64
}

func Optimize

func Optimize(ctx context.Context, optimizers []ImageOptimizer, params OptimizeParams) (*ImageDescription, error)

type ImageOptimizer

type ImageOptimizer interface {
	CanOptimize(mimeType string, acceptedTypes []string) bool
	Optimize(ctx context.Context, sourcePath string, hidpi bool) (*ImageDescription, error)
}

func NewMozjpegLossyOptimizer

func NewMozjpegLossyOptimizer(minSsim float64) ImageOptimizer

func NewMozjpegPngLossyOptimizer

func NewMozjpegPngLossyOptimizer(minSsim float64) ImageOptimizer

func NewWebpLossyJpegOptimizer

func NewWebpLossyJpegOptimizer(minSsim float64) ImageOptimizer

func NewWebpLossyPngOptimizer

func NewWebpLossyPngOptimizer(minSsim float64) ImageOptimizer

type ImageQualityOptimizer

type ImageQualityOptimizer interface {
	OptimizePrecheck(ctx context.Context, sourcePath string) (bool, error)
	OptimizeQuality(ctx context.Context, sourcePath string, quality int) (*ImageDescription, error)
	CompareImages(ctx context.Context, sourcePath string, imageDesc *ImageDescription, hidpi bool) (float64, error)
	ImageOptimizer
}

type MozjpegOptimizer

type MozjpegOptimizer struct {
	Args []string
}

func (*MozjpegOptimizer) CanOptimize

func (o *MozjpegOptimizer) CanOptimize(mimeType string, acceptedTypes []string) bool

func (*MozjpegOptimizer) Optimize

func (o *MozjpegOptimizer) Optimize(ctx context.Context, sourcePath string, hidpi bool) (*ImageDescription, error)

type Name

type Name string

type OptimizeParams

type OptimizeParams struct {
	AcceptedTypes []string
	SourcePath    string
	Hidpi         bool
}

type OptipngOptimizer

type OptipngOptimizer struct {
	Args []string
}

func (*OptipngOptimizer) CanOptimize

func (o *OptipngOptimizer) CanOptimize(mimeType string, acceptedTypes []string) bool

func (*OptipngOptimizer) Optimize

func (o *OptipngOptimizer) Optimize(ctx context.Context, sourcePath string, hidpi bool) (*ImageDescription, error)

type Task

type Task struct {
	OriginalImage *ImageDescription
	Optimizers    []ImageOptimizer
	Hidpi         bool
}

type TaskPool

type TaskPool struct {
	ScoringFunc func([]*ImageDescription, []error) (*ImageDescription, error)
}

func NewTaskPool

func NewTaskPool() *TaskPool

func (*TaskPool) Do

func (p *TaskPool) Do(ctx context.Context, task *Task) (*ImageDescription, error)

type WebpLosslessOptimizer

type WebpLosslessOptimizer struct {
	Args []string
}

func (*WebpLosslessOptimizer) CanOptimize

func (o *WebpLosslessOptimizer) CanOptimize(mimeType string, acceptedTypes []string) bool

func (*WebpLosslessOptimizer) Optimize

func (o *WebpLosslessOptimizer) Optimize(ctx context.Context, sourcePath string, hidpi bool) (*ImageDescription, error)

Jump to

Keyboard shortcuts

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