Extract all images from a pdf as png files (at full resolution)

Alec Jacobson

August 26, 2011

weblog/

Here's a two-liner to extract all the embedded color images in a pdf and convert then to png files. pdfimages extracts the images as ppm files. But I couldn't open these immediately on my mac with my favorite image editing tools, so I convert them with mogrify from the imagemagick suite to png files.
pdfimages original.pdf ./extracted-images
mogrify -format png ./extracted-images*.ppm
and to get rid of the ppm files
rm ./extracted-images*.ppm