Skip to content

Posters asked for ?w= come smaller for every kind of title, not only games - #199

Draft
wittywilla wants to merge 1 commit into
masterfrom
178-poster-sizes
Draft

wittywilla wants to merge 1 commit into
masterfrom
178-poster-sizes

Conversation

@wittywilla

Copy link
Copy Markdown
Owner

Closes #178
Refs #89

What changes

GET /api/items/{id}/poster?w=… now makes a smaller copy for every kind of title. Before, only games got one; films, episodes, music, books and the rest got the original file whatever w said.

  • It's the games' code (GameMeta.PosterThumb), unchanged in what it accepts: only a cache: picture or a picture inside a library folder (Store.LibraryFile), never a remote address, only up to 640 px, snapped to the thumbnail widths, decoded only after its header says it's a picture of at most 16 megapixels. The serving path after it is the same serveArtSrc, so the picture rules (no SVG, sandboxed) still apply.
  • At most two copies are made at once (was half the processors). Each decode holds the picture twice, up to 128 MB for the largest allowed, so a page of new posters on a 20-thread machine could have needed over a gigabyte.
  • The small copies now have a limit: 512 MB, trimmed oldest first with the other caches after a scan (at most once a day). The real artwork in the same folder is never trimmed: trimCache takes a name prefix now, and only gamethumb- files count.
  • The files keep their gamethumb- names, so the games' copies already made stay in use.

The web app doesn't ask with ?w= yet (posterUrl in web/src/api.ts and music's coverUrl): that's #90's, noted for that chat in the shared notes. Until then this changes what the server can do, not what the web app gets. Lists that already ask with w (collections, the video gallery, games) get it now for every kind.

Numbers

Demo media (D:\WittyDemoMedia) scanned by scripts/perf (#89's benchmark), same data folder, base build then this one, Windows, busy machine:

Item Before, ?w=300 After, ?w=300
232 1,660,855 bytes 25,255 bytes
2 515,530 47,234
1308 58,139 17,871
1359 56,315 16,557
144 45,532 12,309
1117 91,014 91,014 (already small enough)

Making a copy took 0.15 to 1.3 s the first time on that busy machine, then it's a file read (15 to 120 ms there).

How it was tested

  • New TestPosterAskedSmallerIsSmaller (internal/server): a 1000×1500 film poster asked ?w=300 comes back as a 320×480 JPEG (410 KiB → 47 KiB for the noisy test picture), without w as the original, and a poster outside the library's folders stays 404 both ways.
  • GOWORK=off go test ./internal/library -run 'PosterThumb|Trim|Cache' and the new server test on Windows: ok. go vet on both packages.
  • Not yet: the whole internal/server run (CI does it; it takes about ten minutes).

Not tried

Changelog line

Posters asked for at a smaller size are made smaller for films, shows, music and books too, not only games, so lists load much less (one demo poster went from 1.6 MB to 25 KB).

🤖 Generated with Claude Code

…games

A grid asks for each poster at a few hundred pixels; films, episodes, music and the
rest got the file beside the media instead, 1.6 MB for one of the demo posters. The
small copies are the games' ones: made once, kept in the image cache, two at a time
at most (each decode can hold 128 MB), and now trimmed to 512 MB with the other caches.

Closes #178
Refs #89

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wittywilla wittywilla added this to the 0.7.0-alpha milestone Nov 4, 2026
@wittywilla wittywilla added the area:performance Speed, memory and FFmpeg label Nov 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:performance Speed, memory and FFmpeg

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Posters are sent at full size: ?w= only makes smaller copies for games

1 participant