Extract Images from PDF

pdftopng converts PDF pages directly to PNG in a single step. Alternatively, pdftoppm (also xpdf-tools) converts to PPM image first, then ImageMagick magick mogrify can batch convert to PNG.

ImageMagick can read PDFs directly but requires a Ghostscript dependency. Skip the extra dependency and use xpdf-tools instead. convert is a built-in Windows command (disk conversion tool), so always prefix with magick when using ImageMagick convert command.

xpdf: Convert Pages to Images

Download latest xpdf-tools from Download Xpdf and XpdfReader.

In this example, xpdf-tools-win-4.06.zip was the latest. Extract the zip archive. Inside xpdf-tools-win-4.06\bin64:

Executable Purpose
pdfdetach.exe Extract embedded file attachments
pdffonts.exe List fonts used
pdfimages.exe Extract raw embedded images, not rendered pages
pdfinfo.exe Show metadata: page count, dimensions, author, dates
pdftohtml.exe Convert to HTML
pdftopng.exe Convert pages to PNG
pdftoppm.exe Convert pages to PPM
pdftops.exe Convert to PostScript
pdftotext.exe Extract text content
# PDF pages to PNG images
pdftopng.exe -r 300 .\document.pdf out

# PDF pages to PPM images
pdftoppm.exe -r 300 .\document.pdf out

Arguments:

  • -r 300 sets the output to 300 DPI resolution.
  • .\document.pdf input PDF file
  • out output filename prefix. Produces one image per page starting with out-000001.png.

Optional: ImageMagick mogrify: PPM to PNG batch conversion

Alternatively, if you used pdftoppm, the ppm images can be bulk converted with ImageMagick mogrify.

magick mogrify -format png .\out*.ppm
  • mogrify ImageMagick subcommand that converts files in-place
  • -format png output format (png)
  • .\out*.ppm glob pattern matching all PPM files in current directory

Output PNG files are written alongside the originals: out-1.png, out-2.png, etc. The source .ppm files are kept.