Skip to content
On this page

    pdftoppm: Convert PDF Pages to Images in One Command

    2 min read

    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 -jpeg or -tiff for 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. pdftoppm appends 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

    FlagFunctionExample
    -pngOutput PNG formatpdftoppm -png input.pdf out/slide
    -jpegOutput JPEG formatpdftoppm -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
    -singlefileWrite one page without page number suffix-f 2 -singlefile
    -jpegopt quality=<n>JPEG compression level (0-100)-jpegopt quality=85

    Tool Comparison

    ToolSetupBest ForTradeoff
    pdftoppmbrew install popplerShell scripts, CLI one-offs, CI pipelinesRequires Poppler binary on host
    PyMuPDFpip install pymupdfPython automation, no system binariesAGPL-3.0 license restrictions
    pypdfium2pip install pypdfium2Permissive Python apps (Apache/BSD)Slower rendering than MuPDF
    pdf2imagepip install pdf2image + PopplerExisting Python codebasesWrapper over pdftoppm

    For local image extraction from a PDF, pdftoppm removes the need for Python.

    What I Learned

    • pdftoppm ships inside the poppler package on Homebrew and apt.
    • slides_output/slide sets both the destination folder and the filename prefix.
    • -r 150 balances resolution and file size for slides; -r 300 gives print quality.
    • -f and -l extract page ranges without pre-splitting the PDF.
    • Calling pdftoppm directly avoids the Python runtime and dependencies of wrapper packages like pdf2image.

    Have a favorite CLI tool that replaced a script? Reach out on LinkedIn.