On this page
pdftoppm: Convert PDF Pages to Images in One Command
Today I found pdftoppm and stopped writing throwaway Python scripts to turn slide decks into images.
I had a 15-page presentation PDF and needed 15 standalone slide images in a folder for a review. I used to upload files to web converters or write Python scripts with pdf2image. pdftoppm handles the conversion in the terminal with one command.
The One-Line Command
Install Poppler:
# macOS
brew install poppler
# Ubuntu / Debian
sudo apt install poppler-utils
Run pdftoppm:
mkdir -p slides_output
pdftoppm -png -r 150 presentation.pdf slides_output/slide
For a 15-page document, this writes slide-01.png through slide-15.png into slides_output/.
Flag breakdown:
-png: Output PNG files. Use-jpegor-tifffor other formats.-r 150: Set resolution to 150 DPI. Web and slide decks stay sharp at 150 DPI without ballooning file size.presentation.pdf: Input file.slides_output/slide: Output directory and filename prefix.pdftoppmappends the page number.
Useful Recipes
Extract a page range (slides 1 to 5):
pdftoppm -png -r 150 -f 1 -l 5 presentation.pdf slides_output/slide
High-resolution images for print (300 DPI):
pdftoppm -png -r 300 document.pdf print_output/page
Extract a single page without the number suffix:
pdftoppm -png -r 150 -f 3 -singlefile presentation.pdf slide_3
Convert to compressed JPEG with quality control:
pdftoppm -jpeg -r 150 -jpegopt quality=85 presentation.pdf slides_output/slide
Quick Reference
| Flag | Function | Example |
|---|---|---|
-png | Output PNG format | pdftoppm -png input.pdf out/slide |
-jpeg | Output JPEG format | pdftoppm -jpeg input.pdf out/slide |
-r <dpi> | Set DPI resolution | -r 150 (web) or -r 300 (print) |
-f <n> | First page to convert | -f 1 |
-l <n> | Last page to convert | -l 5 |
-singlefile | Write one page without page number suffix | -f 2 -singlefile |
-jpegopt quality=<n> | JPEG compression level (0-100) | -jpegopt quality=85 |
Tool Comparison
| Tool | Setup | Best For | Tradeoff |
|---|---|---|---|
| pdftoppm | brew install poppler | Shell scripts, CLI one-offs, CI pipelines | Requires Poppler binary on host |
| PyMuPDF | pip install pymupdf | Python automation, no system binaries | AGPL-3.0 license restrictions |
| pypdfium2 | pip install pypdfium2 | Permissive Python apps (Apache/BSD) | Slower rendering than MuPDF |
| pdf2image | pip install pdf2image + Poppler | Existing Python codebases | Wrapper over pdftoppm |
For local image extraction from a PDF, pdftoppm removes the need for Python.
What I Learned
pdftoppmships inside thepopplerpackage on Homebrew and apt.slides_output/slidesets both the destination folder and the filename prefix.-r 150balances resolution and file size for slides;-r 300gives print quality.-fand-lextract page ranges without pre-splitting the PDF.- Calling
pdftoppmdirectly avoids the Python runtime and dependencies of wrapper packages likepdf2image.
Have a favorite CLI tool that replaced a script? Reach out on LinkedIn.