Thumbnail encoding study shipped
Every grid thumbnail ends a chain of choices: format, quality, chroma subsampling, resolution. Here I run one photo through all of them with real byte counts, so you can see the tradeoffs instead of taking them on faith. The actual encoders the site uses (avifenc, jpegli, cwebp, sips) produced every number.
The verdict shipped: the live pipeline (holding/scripts/add-photos.sh)
encodes every thumbnail as AVIF-primary + a jpegli q82 JPG fallback. That combination
wins below, and it's why the site builds jpegli from source.
Format showdown
The same detailed color frame at 400×266px. PNG holds the lossless
baseline; everything below it throws bits away. Eyeball the quality, then read the bytes.
b/px = bytes per pixel, the size-density that actually scales.











Why the site builds jpegli from source
Look at the two q82 JPEGs above: system/sips lands at 31.7 KB,
jpegli at 16.8 KB: same nominal
quality, ~47% fewer bytes.
Google's jpegli re-implements libjpeg and tunes it psychovisually; that win alone
is why ~/.local/bin/cjpegli exists and the pipeline shells out
to it instead of the OS encoder. AVIF beats both, but JPEG still backs up
every <img> as the universal fallback, so shrinking it still pays off.
Grayscale: drop the chroma planes
A black-and-white Leica frame (400×267). In a grayscale image the
two chroma planes carry almost nothing, so AVIF 4:0:0 (luma only) both encodes it
honestly and rules out any faint color cast. Dropping to 4:0:0 saves barely any bytes over 4:2:0
because nothing lived in those planes to begin with. Correctness drives this,
not size. The pipeline detects sips -g space → Gray and
switches to --yuv 400.




Resolution scales bytes ~quadratically
The color frame at three long edges, AVIF q63 vs jpegli q82. Doubling the long edge roughly triples the bytes, and AVIF holds a steady ~35–38% lead over JPEG at every size, which is why the grid stays AVIF-primary and small and square.
| resolution | AVIF q63 | jpegli q82 | AVIF saves |
|---|---|---|---|
| 400×266 | 10.4 KB | 16.8 KB | 38% |
| 800×533 | 33.3 KB | 54.1 KB | 38% |
| 1200×800 | 73.1 KB | 112.9 KB | 35% |
What aadhar.sh actually ships
- AVIF primary (
q63,4:2:0color /4:0:0gray) + jpegli JPG q82 as the universal fallback, via<picture>. - Pre-cropped 600/400 squares, metadata-stripped: the file holds exactly the displayed pixels, so no off-square or EXIF bytes ride along.
- 4:2:0 over 4:4:4 for color: storing the full chroma at 4:4:4 costs ~8% more bytes (the two AVIF q63 cards above) and buys no visible gain at thumbnail size, so 4:2:0 hands you free quality.
- Full-res share copies in R2 at JPEG q95: visually lossless, half the bytes of q100; the true HEIF originals stay on local disk.