"Documents are mostly flat color, so rendered pages come out smaller as PNG than as JPEG." I'd have half believed that myself: I spent three years on codecs, and flat regions really are where DCT suffers. PDF rendering isn't something I've built, so the claim was put to a test on 2026-11-13 with a self-made 3-page A4 PDF: a text page with Chinese body text from 10.5 pt down to 5 pt plus a 0.3 pt hairline table, a chart page with vector bars, lines and a pie, and a photo page. Poppler rendered each page at 216 DPI on white; Pillow and pngquant encoded the same pixels in each format. One Apple silicon Mac, one run per setting. PNG won one page out of three.
Same render, three pages, three verdicts
On the chart page the claim holds: PNG was 127,051 bytes, lossless, against 178,232, 201,943 and 233,599 for JPEG q75, q85 and q92. On the text page it falls apart. PNG was 838,404 bytes and JPEG q92 was 796,608 at 45.92 dB, so the "obviously smaller" format is about 5% bigger. On the photo page PNG was 2,431,138 bytes against 550,440 for JPEG q92, which nobody will find surprising.
The color count points the wrong way too. On a quarter-scale copy, the text page has about 447 colors and 81% white, the chart page about 2,117 colors and 82% white, the photo page about 26,914 colors and 49% white. The page where PNG wins has almost five times the colors of the page where it loses. My reading, which is inference rather than measurement: dense antialiased glyphs leave deflate few long runs, while big flat fills with hard edges make every JPEG block on a boundary pay for ringing. That ringing was counted, as the share of pure-white pixels 1 to 3 pixels from a stroke that moved more than 8 levels after encoding (my own metric, not a standard one). JPEG q75 grayed 11.69% of them on the text page and 10.13% on the chart page; q92 brought that to 0.40% and 0.70%.
Encoder effort moved the line again
For a real browser export, the same three pages went through ImgIng https://imging.ai/ in desktop Chromium on the same Mac, at 216 DPI. It converts in the browser, offers 144, 216 and 300 DPI with 216 as default, and exports PNG, JPEG or WebP. There PNG lost on every page: 881,244 against 818,045 bytes on text, 228,983 against 194,664 on charts, and 3,658,462 against 476,565 on the photo page. That last one is 7.7 times the JPEG, while JPEG and WebP sat at 44.49 and 44.62 dB against the PNG.
The exported PNG pixels were then re-encoded unchanged with Pillow's optimize. Text went from 881,244 to 602,883 bytes, 32% smaller, and charts from 228,983 to 125,175, so both now beat the JPEG. My guess is that the browser's PNG encoder uses a lighter deflate setting; that code isn't mine and its settings weren't checked. Back on the poppler renders, the smallest lossless result on both non-photo pages wasn't PNG anyway: WebP lossless gave 161,212 and 37,390 bytes, smaller even than a lossy 256-color palette PNG at 359,391 and 49,019.
Pick the format per page and write down why
If I designed the encode step of a rendering service, and this isn't my module, I wouldn't set one format. I'd compute cheap signals on a small copy of each page, let them pick lossy or lossless per page, and store the reason with the output. Roughly this shape, filled with the text-page numbers (a sketch, not output from a running service):
{
"page": 1, "dpi": 216,
"signals": {"colors_quarter_scale": 447, "white_share": 0.81},
"bytes": {"png": 838404, "jpeg_q92": 796608, "webp_lossless": 161212},
"chosen": "webp_lossless",
"reason": "downstream needs lossless text; smallest lossless candidate"
}
Without a reason field, six months later there's no way to tell why page 14 is JPEG and page 15 is WebP short of rerunning the pipeline. It also lets you replay old decisions against new thresholds. I have no thresholds to offer: this is one sample with no scans, handwriting or CMYK pages, and I don't know where a half-photo, half-text page should flip. The sample is self-made; the photo on page 3 is a CC0 image by Bonnie Moreland from Wikimedia Commons. Whatever converter you use, zoom into the smallest text afterwards and check it still looks like the source. If you own a pipeline, encode three of your own pages as PNG with strong deflate, JPEG q92 and WebP lossless, and log bytes and PSNR per page.
Top comments (0)