manager

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: Apache-2.0 Imports: 15 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
	FixedResolutions []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) MatchOrResize added in v0.0.16

func (rs Resolutions) MatchOrResize(requested, source image.Rectangle) image.Rectangle

MatchOrResize returns the resolution which match one of the resolution, or a resolution that fits in the requested resolution, keeping the ratio of the source image.

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