resizer

package
v0.0.0-...-6ed391b Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrImgDecode   = errors.New("could not decode image")
	ErrNoImage     = errors.New("no image found")
	StatusCreated  = "CREATED"
	StatusFinished = "FINISHED"
	StatusFailed   = "FAILED"
)

Functions

This section is empty.

Types

type ClockUTC

type ClockUTC struct{}

func (ClockUTC) Now

func (c ClockUTC) Now() time.Time

type Clocker

type Clocker interface {
	Now() time.Time
}

type Converter

type Converter interface {
	Transform(raw *[]byte) (image.Image, error)
	Resize(img *image.Image, width, height uint) ([]byte, error)
}

type ConverterPNG

type ConverterPNG struct{}

func (ConverterPNG) Resize

func (cnv ConverterPNG) Resize(img *image.Image, width, height uint) ([]byte, error)

func (ConverterPNG) Transform

func (cnv ConverterPNG) Transform(raw *[]byte) (image.Image, error)

type Hasher

type Hasher interface {
	Gen(raw *[]byte) string
}

type HasherMD5

type HasherMD5 struct{}

func (HasherMD5) Gen

func (h HasherMD5) Gen(raw *[]byte) string

type Image

type Image struct {
	Id        string
	Image     image.Image
	CreatedAt time.Time
}

type ImageService

type ImageService interface {
	Create(ctx context.Context, raw *[]byte) (*Image, error)
	Read(ctx context.Context, imgId string) (*Image, error)
	Delete(ctx context.Context, imgId string) error
	ScheduleResizeJob(ctx context.Context, imgId string, width, height uint) (*ResizeJob, error)
	GetResizeJob(ctx context.Context, jobId uint64) (*ResizeJob, error)
}

type ResizeJob

type ResizeJob struct {
	Id        uint64
	Status    string
	Image     image.Image
	CreatedAt time.Time
}

type ResizeService

type ResizeService interface {
	SendResizeJob(ctx context.Context, req *ResizeServiceRequest) error
	RunResizeWorker(ctx context.Context, ch chan uint64) error
}

type ResizeServiceRequest

type ResizeServiceRequest struct {
	JobId  uint64
	RawImg []byte
	Width  uint
	Height uint
}

Jump to

Keyboard shortcuts

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