Bulk Export Images to JPG from PDF – bash one liner

Sometimes I forget what power there is in free software. I put this quickie together the other day. Just be aware that it won’t handle any spaces in the PDF filename.

for i in *.pdf;do pdfimages $i ${i%.*};done && for i in *.ppm;do ppmtojpeg $i >> ${i%.*}.jpg;done; rm -f *.ppm

images are exported as -00n.jpg – ie: the n’th image found in the pdf.

Published by salubrium

I am a Systems Administrator based in Sydney, Australia with some hugely varied interests: Topics covered are Virtualization, Web Hosting, Remote Desktop, Security and Backups, PHP, Python, MVC Frameworks, SEO

Join the Conversation

2 Comments

  1. it took me a while to figure out, but to handle spaces in filenames for that kind of bash-loop, you quote the second argument, it does not work with backtic args like: for i in `ls *gif`;

    for i in *.pdf; do pdfimages “$i” ; done

  2. Wow – thanks for this! Exactly what I was looking for. I seemed to remember there being an export image function in Acrobat but couldn’t find it… Any way to have the images exported with a white background? (mine all had black ones).

    Nadine

Leave a comment

Your email address will not be published.