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