manager

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseResolution

func ParseResolution(s string) (image.Rectangle, error)

ParseResolution returns an image.Rectangle representing the resolution given as a string

Types

type Config

type Config struct {
	Quality      int
	Resolutions  []string
	Cache        string
	CacheDrivers map[string]map[string]interface{}
}

Config is the config for the Thumbnail service

type FileType

type FileType int

FileType is the output format of the thumbnail

const (
	// PNGType is the value to specify a PNF output
	PNGType FileType = iota
	// JPEGType is the value to specify a JPEG output
	JPEGType
	// BMPType is the value to specify a BMP output
	BMPType
)

type Resolutions

type Resolutions []image.Rectangle

Resolutions is a list of image.Rectangle representing resolutions.

func ParseResolutions

func ParseResolutions(strs []string) (Resolutions, error)

ParseResolutions creates an instance of Resolutions from resolution strings.

func (Resolutions) ClosestMatch

func (rs Resolutions) ClosestMatch(requested image.Rectangle, sourceSize image.Rectangle) image.Rectangle

ClosestMatch returns the resolution which is closest to the provided resolution. If there is no exact match the resolution will be the next higher one. If the given resolution is bigger than all available resolutions the biggest available one is used.

type Thumbnail

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

Thumbnail is the service that generates thumbnails

func NewThumbnail

func NewThumbnail(d downloader.Downloader, c *Config, log *zerolog.Logger) (*Thumbnail, error)

NewThumbnail creates a new Thumbnail service that generates thumbnails

func (*Thumbnail) GetThumbnail

func (t *Thumbnail) GetThumbnail(ctx context.Context, file, etag string, width, height int, outType FileType) ([]byte, string, error)

GetThumbnail generate a thumbnail from the file, returning the thumb and the mimetype of the thumb. The mimetype depends on the out type (PNG, JPEG, BMP). If a cache is enabled in the configuration, it will first check if the file with the given etag was already generated and saved into the cache.

Jump to

Keyboard shortcuts

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