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. w and h determine the maximum dimensions of the thumbnails.
func (*Cache) Get ¶
Get the file path to the thumbnail of the file with the given id. Generate 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.