Documentation ¶
Overview ¶
Package thumb implements a lazy image thumbnail cache. Supported input image formats are any format Go can decode natively from the standard library and subrepo golang.org/x/image.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeFunc ¶
DecodeFunc returns a func that can be used to decode the image with the given file name, or nil if it's not supported. TODO: sniff magic number instead of only using file extension TODO: allow externally registered format decoders
func FormatSupported ¶
FormatSupported returns true if the given file extension belongs to an image format that can be thumbnailed by this package.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a lazy, concurrent thumbnail cache for airlift-server with request batching for on-the-fly thumbnail generation. Only file paths are cached in memory.
func NewCache ¶
NewCache initializes a new thumbnail generator that stores files encoded from store by enc in dirPath, using scaler to resample images.
func (*Cache) Get ¶
Get returns the file path to the thumbnail of the file with the given id, generating it if it doesn't exist already. If concurrent requests are made to the same non-existent thumbnail, it will only be generated once.
TODO: error handling
type Encoder ¶
type Encoder interface { Extension() string // The file extension of the resulting image Encode(dst io.Writer, thumb image.Image) error }
Encoder describes a way to encode a thumbnail image.