imgart

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2019 License: MIT Imports: 7 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(imgFormat string, img image.Image, quality int) ([]byte, error)

Encode image by their format (png, jpeg, bmp)

Types

type Cache

type Cache interface {
	// Get value by a given key
	Get(key string) ([]byte, error)
	// Set value
	Set(key string, value []byte, expiration time.Duration) error
}

Cache interface

type Effect

type Effect interface {
	// ID that identifies the effect
	ID() string

	// Description of the effect
	Description() string

	// Parameters required for the transform
	Parameters() Parameters

	// Transform applies the specific transformation to the given image
	Transform(ctx context.Context, img image.Image, params map[string]interface{}) (image.Image, error)
}

Effect represents an image transformation (ex: rotate, resize, overlay...)

type EffectRepository

type EffectRepository interface {
	// GetEffects return all available effects
	GetEffects() ([]Effect, error)
	// GetEffect returns an effect by the given id
	GetEffect(id string) (Effect, error)
}

EffectRepository to store effects

type Filter

type Filter struct {
	// ID of the effect
	ID string `json:"id" bson:"filters"`
	// Parameters to apply
	Parameters map[string]interface{} `json:"parameters" bson:"parameters"`
}

Filter represents an effect with all parameters

type ImageRepository

type ImageRepository interface {
	// Get an image by the given path
	Get(ctx context.Context, path string) (image.Image, string, error)
}

ImageRepository interface layer to get images

type ImageService

type ImageService interface {
	// Effects returns all available effects for the image
	Effects() ([]Effect, error)
	// Effect returns a effect by the given ID
	Effect(id string) (Effect, error)
	// Process an image with a set of filters
	Process(ctx context.Context, imgSrc string, filters []Filter) (image.Image, string, error)
}

ImageService interface has the logic for processing images by the given a list of filters

type Parameter

type Parameter struct {
	Description string      `json:"description"`
	Required    bool        `json:"required"`
	Type        string      `json:"type"`
	Example     interface{} `json:"example"`
	Default     interface{} `json:"default,omitempty"`
	Values      interface{} `json:"values,omitempty"`
}

Parameter contains all properties of a single effect parameter

type Parameters

type Parameters map[string]Parameter

Parameters it's a map that contains all parameters of an effect

type Profile

type Profile struct {
	ID      string    `json:"id" bson:"_id"`
	Created time.Time `json:"created" bson:"created"`
	Updated time.Time `json:"updated" bson:"updated"`
	Filters []Filter  `json:"filters" bson:"filters"`
}

Profile that represents a set of effects

type ProfileRepository

type ProfileRepository interface {
	GetAll(limit int, skip int) (*[]Profile, error)
	Get(id string) (*Profile, error)
	Create(profile *Profile) error
	Update(profile *Profile) error
	Delete(id string) error
}

ProfileRepository stores profiles

type ProfileService

type ProfileService interface {
	GetAll(limit int, skip int) (*[]Profile, error)
	Get(id string) (*Profile, error)
	Create(profile *Profile) error
	Update(profile *Profile) error
	Delete(id string) error
}

ProfileService handles profile operations

Jump to

Keyboard shortcuts

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