HeadlinesBriefing favicon HeadlinesBriefing.com

Why Tiny JPEGs Look Different in Chrome

Hacker News •
×

What looked like a rendering bug turned out to be a clever JPEG decoding optimization in Chrome. A colleague noticed a logo looked thicker in Chrome than in Firefox. Swapping to SVG fixed it, but curiosity led to digging.\n\nScaling down images can be wasteful.

For a 2000×2000 JPEG displayed at 20×20, full decompression uses ~12 MB but final image only ~1.2 KB. Most information lost is high-frequency detail, similar to a tree becoming a green blob and brown stick when scaled.\n\nJPEG splits images into 8×8 blocks and converts them to frequency domain via DCT. When scaling by 1/8, each block can become one pixel.

Chrome's Skia uses libjpeg-turbo with partial IDCT scaling to decode only low-frequency coefficients, skipping high frequencies that would be lost anyway. This makes the image look thicker because only the constant component remains.\n\nThe moral: don't use JPEG for icons; it's optimized for photos, as in "Joint Photographic Experts Group.".