Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
SupportedMimeTypes = [...]string{
"image/png",
"image/jpg",
"image/jpeg",
"image/gif",
"text/plain",
}
)
Functions ¶
func IsMimeTypeSupported ¶
Types ¶
type Encoder ¶
type Encoder interface { // Encode encodes the image to a format. Encode(io.Writer, image.Image) error // Types returns the formats suffixes. Types() []string // MimeType returns the mimetype used by the encoder. MimeType() string }
Encoder encodes the thumbnail to a specific format.
func EncoderForType ¶
EncoderForType returns the encoder for a given file type or nil if the type is not supported.
type JpegEncoder ¶
type JpegEncoder struct{}
JpegEncoder encodes to jpg.
func (JpegEncoder) MimeType ¶
func (e JpegEncoder) MimeType() string
MimeType returns the mimetype for jpg files.
type Manager ¶
type Manager interface { // Generate will return a thumbnail for a file Generate(Request, image.Image) ([]byte, error) // Get loads the thumbnail from the storage. // It will return nil if no image is stored for the given context. Get(Request) ([]byte, bool) }
Manager is responsible for generating thumbnails
type PngEncoder ¶
type PngEncoder struct{}
PngEncoder encodes to png
func (PngEncoder) MimeType ¶
func (e PngEncoder) MimeType() string
MimeType returns the mimetype for png files.
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 SimpleManager ¶
type SimpleManager struct {
// contains filtered or unexported fields
}
SimpleManager is a simple implementation of Manager
func NewSimpleManager ¶
func NewSimpleManager(resolutions Resolutions, storage storage.Storage, logger log.Logger) SimpleManager
NewSimpleManager creates a new instance of SimpleManager