Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 Resolutions ¶
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.