PDF image conversion

Someone silly sent me a metric fuckton of images embedded in PDFs. They wanted this stuff on the intertubez and they wanted it now. I’m lazy, so I automated the process. Figured I would write it down so I can remember it.

Imagemagick’s convert tool was my first weapon of choice, but this resulted in really poor output. So I decided to combine it with the pdfimages tool. The following snippet assumes the PDF contains only one image of interest.

pdfimages input.pdf tmp
convert tmp-000.ppm output.jpg

Wrap a loop around it and you’re done. It’s almost too simple to be true.

Leave a Reply

Your email address will not be published. Required fields are marked *