Documentation
¶
Overview ¶
Package artwork serves and makes Ether's artwork: a caching proxy for TMDB images (memory LRU over a disk cache) and a pure-Go poster generator for collections (collage and backdrop treatments with the title set in the Go fonts).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidPath rejects anything that is not a TMDB image path. ErrInvalidPath = errors.New("artwork: not a TMDB image path") // ErrNotFound means the image does not exist upstream. ErrNotFound = errors.New("artwork: image not found") )
Functions ¶
func Compose ¶
func Compose(req PosterRequest, posters, backdrops []image.Image) *image.RGBA
Compose draws a poster from already-decoded images. It is pure, so tests can check its output without a network.
collage 2×2 (4+ posters) or 3×2 (6 posters) tiles under a gradient
backdrop a member backdrop cropped to portrait with a title treatment
auto collage with 4+ posters, else backdrop, else a single poster,
else a typographic poster in the accent colour
Types ¶
type ImageSource ¶
ImageSource loads TMDB images; *Images satisfies it.
type Images ¶
type Images struct {
// contains filtered or unexported fields
}
Images is a caching TMDB image store. Concurrent requests for the same image share one fetch. Safe for concurrent use.
type ImagesOptions ¶
type ImagesOptions struct {
// Dir is the disk cache directory ("" = memory only).
Dir string
// MemoryBytes bounds the in-memory LRU (default 64 MiB).
MemoryBytes int64
// DiskBytes bounds the disk cache (default 512 MiB).
DiskBytes int64
// HTTPClient fetches images (default: 20 s timeout).
HTTPClient *http.Client
// ImageURL builds TMDB URLs (default image.tmdb.org).
ImageURL core.ImageURLFunc
Logger *slog.Logger
}
ImagesOptions configure an image store.
type PosterRequest ¶
type PosterRequest struct {
Title string `json:"title"`
Subtitle string `json:"subtitle,omitempty"` // small caps line above the title, e.g. "24 FILMS"
Mode string `json:"mode"` // auto | collage | backdrop
Accent string `json:"accent,omitempty"` // "#rrggbb"; derived from the artwork when empty
Posters []string `json:"posters,omitempty"` // member poster paths (up to 6 used)
// Backdrops are member backdrop paths (the first that loads is used).
Backdrops []string `json:"backdrops,omitempty"`
Width int `json:"width"` // output width; height is 1.5×
}
PosterRequest describes a collection poster.
func (PosterRequest) String ¶
func (r PosterRequest) String() string
String describes a request (logs).
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer makes collection posters and caches them on disk, keyed by everything that affects the pixels (title, mode, accent, members, size).
func NewRenderer ¶
func NewRenderer(src ImageSource, dir string, log *slog.Logger) *Renderer
NewRenderer creates a renderer. dir "" disables the disk cache.