Every few weeks someone asks a variant of the same question: "how do I get these PDF pages
into PNG images?" — for slides thumbnails, for embedding pages in docs, for feeding pages
into an OCR model. There are a lot of answers, and most of them are slower than they need
to be.
I generated a synthetic 20-page PDF (US Letter, text + vector shapes) and ran the
contenders at 150 DPI on the same machine. Here's what I found.
The benchmark
| Method | 20 pages @150 DPI | Throughput |
|---|---|---|
| macOS Preview / Acrobat (manual export) | ~2 min of clicking | — |
pdftoppm (poppler) |
4.1 s | 4.8 pages/s |
| Ghostscript one-liner | 0.9 s | 21.2 pages/s |
| PyMuPDF (Python) | 0.7 s | 29.4 pages/s |
| Web converter | upload-bound | — |
The spread surprised me: the "standard" poppler route is 6× slower than PyMuPDF on the
same document.
1. Preview / Acrobat — for one or two pages
Fine for a single page. Painful for 20. If you're exporting more than a handful of pages,
anything scripted below wins immediately.
2. pdftoppm — the default answer
pdftoppm -png -r 150 input.pdf page
# -> page-01.png, page-02.png, ...
Preinstalled almost everywhere, dead simple, and slow — 4.1 s for 20 pages here. It's also
what the popular pdf2image Python package shells out to under the hood, so that package
inherits the same speed.
3. Ghostscript — the quiet workhorse
gs -q -dNOPAUSE -dBATCH -sDEVICE=png16m -r150 \
-sOutputFile=page-%02d.png input.pdf
One process renders every page (the %02d pattern handles numbering), at 21 pages/s.
Already installed on most servers.
4. PyMuPDF — the speed winner
import pymupdf
doc = pymupdf.open("input.pdf")
for i, page in enumerate(doc):
pix = page.get_pixmap(matrix=pymupdf.Matrix(150 / 72, 150 / 72)) # 150 DPI
pix.save(f"page-{i+1:02d}.png")
29 pages/s, no subprocess overhead, and you control the DPI with a zoom matrix
(150/72 ≈ 2.08× — a 612×792 pt page becomes 1275×1650 px, ~187 KB per page here).
If you're doing anything programmatic — thumbnails, OCR preprocessing, page previews —
this is the one to pick.
5. A web converter — when you can't install anything
Locked-down work laptop, one-off task, or the PDF lives on your phone? Then a browser
tool is the pragmatic choice; I've used
iloveconvert.com's PDF to PNG converter
for exactly this — it bundles multi-page output and saves you the local setup entirely.
Takeaways
- For scripting: PyMuPDF, ~6× faster than the poppler default.
- For a server you already SSH into: the Ghostscript one-liner is already there.
- Save yourself the manual Preview export — anything past 2 pages isn't worth the clicks.
Top comments (0)