Documentation ¶
Index ¶
- func WithCacheDir(dir string) optFunc
- func WithCacheMaxNum(num int) optFunc
- func WithCacheMaxSize(size size.S) optFunc
- func WithCreateDirs(b bool) optFunc
- func WithImageDefaults(id ImageDefaults) optFunc
- func WithImagePresets(presets []ImagePreset) optFunc
- func WithLogLevel(s string) optFunc
- func WithLogger(l *log.Logger) optFunc
- func WithOriginalsDir(dir string) optFunc
- func WithSetPermissions(b bool) optFunc
- type CacheStat
- type ErrIdNotFound
- type Format
- type ImageDefaults
- type ImageHandler
- func (h *ImageHandler) Add(r io.Reader) (int, error)
- func (h *ImageHandler) Delete(id int) error
- func (h *ImageHandler) Get(params ImageParameters) (string, error)
- func (h *ImageHandler) GetPreset(preset string) (ImagePreset, bool)
- func (h *ImageHandler) Ids() ([]int, error)
- func (h *ImageHandler) Stat() (Stat, error)
- func (h *ImageHandler) StatId(id int) (ImageStat, error)
- type ImageParameters
- type ImagePreset
- type ImageStat
- type Interpolation
- type Logger
- type Stat
- type SubImager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithCacheMaxNum ¶
func WithCacheMaxNum(num int) optFunc
WithCacheMaxNum sets the cache max number option
func WithCacheMaxSize ¶
WithCacheMaxSize sets the cache max size.size option
func WithCreateDirs ¶
func WithCreateDirs(b bool) optFunc
WithCreateDirs sets the create directories option
func WithImageDefaults ¶
func WithImageDefaults(id ImageDefaults) optFunc
WithImageDefaults sets defaults used when no preset or parameters are given
func WithImagePresets ¶
func WithImagePresets(presets []ImagePreset) optFunc
WithImagePresets adds the given set of presets to the handler
func WithOriginalsDir ¶
func WithOriginalsDir(dir string) optFunc
WithOriginalsDir sets the originals directory
func WithSetPermissions ¶
func WithSetPermissions(b bool) optFunc
WithSetPermissions sets the set permissions option
Types ¶
type ErrIdNotFound ¶
func (ErrIdNotFound) Error ¶
func (e ErrIdNotFound) Error() string
func (ErrIdNotFound) Is ¶
func (e ErrIdNotFound) Is(err error) bool
type ImageDefaults ¶
type ImageDefaults struct { Format Format QualityJpeg int QualityGif int Width int Height int MaxSize size.S Interpolation }
func (ImageDefaults) String ¶
func (id ImageDefaults) String() string
type ImageHandler ¶
type ImageHandler struct {
// contains filtered or unexported fields
}
ImageHandler is the main type of this package.
func New ¶
func New(optFuncs ...optFunc) (*ImageHandler, error)
New creates a new Imageandler and applies the given options.
TODO: MUST create a cache based on files in cache folder on startup
func (*ImageHandler) Add ¶
func (h *ImageHandler) Add(r io.Reader) (int, error)
Returns id of the added image
func (*ImageHandler) Delete ¶
func (h *ImageHandler) Delete(id int) error
func (*ImageHandler) Get ¶
func (h *ImageHandler) Get(params ImageParameters) (string, error)
returns the path to the processed image.
func (*ImageHandler) GetPreset ¶
func (h *ImageHandler) GetPreset(preset string) (ImagePreset, bool)
func (*ImageHandler) Ids ¶
func (h *ImageHandler) Ids() ([]int, error)
TODO: page and chunk as arguments for when we have thousands of ids?
func (*ImageHandler) Stat ¶
func (h *ImageHandler) Stat() (Stat, error)
type ImageParameters ¶
type ImageParameters struct { Id int Format // Jpeg:1-100, Gif:1-256 Quality int // width and Height in pixels (0 = keep aspect ratio, both width and height can not be 0) Width uint Height uint // Max file-size in bytes (0 = no limit) MaxSize size.S }
func (*ImageParameters) String ¶
func (ip *ImageParameters) String() string
type ImagePreset ¶
type ImagePreset struct { Name string Alias []string Format Format Quality int Width int Height int MaxSize size.S Interpolation }
func (ImagePreset) String ¶
func (ip ImagePreset) String() string
type Interpolation ¶
type Interpolation string
Interpolation represents interpolation methods used when resizing images.
const ( NearestNeighbor Interpolation = "nearestNeighbor" Bilinear Interpolation = "bilinear" Bicubic Interpolation = "bicubic" MitchellNetrav Interpolation = "MitchellNetravali" Lanczos2 Interpolation = "lanczos2" Lanczos3 Interpolation = "lanczos3" )
func ParseInterpolation ¶
func ParseInterpolation(s string) (Interpolation, error)
func (Interpolation) String ¶
func (r Interpolation) String() string