pdf-quiz-generator/backend
Daniel cedab6e91e feat: thumbnails for uploaded images, at two widths and no others
A question's stem image is two to four megabytes of scanned radiograph, and a
media grid is forty of those pulled at full size to draw forty postage stamps.
`?w=256` and `?w=640` now serve a WebP copy instead, made on the first ask and
kept beside the original under `thumbs/{width}/{key}` — same bucket, so nothing
new has to be configured for them to be backed up or thrown away.

Three rules, all about not making this a way to spend the server's afternoon.
Those two widths and no others: any other `?w=` is refused with a 400, because
an endpoint that resizes to whatever the query string asks for is a CPU sink
anybody can point at. Never enlarged: a 180px image asked for at 640 is served
as it is, since scaling up invents detail and charges bytes for it. And best
effort throughout — a PDF, an SVG, a truncated upload or a file that is not the
image its name claims all serve their original rather than failing, because a
preview must never take down the page that wanted it.

Authorisation is unchanged and still runs first: a thumbnail of a file you may
not read is a file you may not read. They stay `private, no-store` like
everything else here — they are behind authentication, so there is nothing for
a shared cache to do with them, and the win is the byte count.

EXIF rotation is read before anything measures the image. Every phone stores a
portrait photograph sideways with a flag; a thumbnail made without reading it
is a sideways thumbnail.

Pillow rather than sharp, which is Node. It is not pinned in requirements: the
pin invalidates the pip layer, and that layer no longer builds because
litellm==1.28.13 has been withdrawn from PyPI. Re-pinning litellm is a
deliberate upgrade of the AI layer, not something to slip into this. Noted in
the TODO.

Also: the article hover-card excerpt was printing `[[288|eczema]]` at readers.
The generic markdown-link rule does not know our own cross-reference syntax, so
it left the brackets and the id behind.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TqXevQJhxFrM7jJg82cgZN
2026-09-12 08:49:20 +02:00
..
alembic refactor: remove per-question sharing 2026-09-12 08:42:51 +02:00
app feat: thumbnails for uploaded images, at two widths and no others 2026-09-12 08:49:20 +02:00
scripts fix: the ear to ENT, gynecology to its own branch, and Surgery back into medicine 2026-09-12 08:06:59 +02:00
tests feat: thumbnails for uploaded images, at two widths and no others 2026-09-12 08:49:20 +02:00
.dockerignore Initial commit: PDF Quiz Generator app 2026-03-30 20:04:53 +00:00
.env.example feat: Cap replaces hCaptcha, self-hosted beside the app 2026-09-12 06:14:14 +02:00
alembic.ini Wire Alembic to live Postgres and fix startup DDL race 2026-04-14 04:49:23 +02:00
Dockerfile Initial commit: PDF Quiz Generator app 2026-03-30 20:04:53 +00:00
manage.py Cross-browser job tracking, hamburger fix, CLI extract, quiz delete keeps bank questions 2026-04-01 02:30:47 +02:00
requirements.txt build: pin litellm 1.28.13 after 1.27.8 was yanked from PyPI 2026-09-07 16:18:35 +02:00