Extracting images from PDF (free, using command line)

This is a day when I love computers. I have a multipage PDF and I need to extract the images from it.

Option 1: Open the PDF on screen, capture each section, save each file.
No thanks, that’ll take far too long and lose quality (which already isn’t too great)

Option 2: Open the PDF using Adobe Illustrator. select each image, copy/crop/save as, etc.
No thanks, almost as bad as option 1

Option 3: Google for an answer to “Extract images from PDF”. Discover all the top results are for paid applications.
No thanks. I don’t mind paying for applications but this is a (probably) one off job and I feel sure someone would have written a script to extract all the images from a PDF.

Option 4: Try PDFtk, a PDF toolkit that takes instructions by command line.
Almost there. It can do all sorts of things to PDFs, but extract the image objects appears not to be one of them.

Option 5: Re-discover The Unarchiver
t works! It really was so simple. The Unarchiver views PDF files as if they were a compressed file. Select the PDF, tell it to extract all.  Voila! 652 tiff images from 44 pages of PDF.  20 minutes to find the solution. Maybe 2 seconds for unarchiver to run (oh, and I already had it on my Mac, probably from having to extract a less common file archive format).

One last note. It maybe that ghostscript could also do this task, that would have been my option 6…


7 responses to “Extracting images from PDF (free, using command line)”

  1. You saved my day.
    Too bad this does not work on Windows.

  2. Thanks so much for this.

    I had no idea I could use The Unarchiver for that! Awesome.

  3. The Unarchiver… such an awesome solution! Many thanks!!

  4. Nice knowledge sharing post. Preview already has an export feature for free, and Unarchiver can do these for each individual image even! Now that’s two tools I find that mac has and I need one for windows at work, haha, joy.

  5. Natasha Woods

    Hah, this was great thanks! Have you noticed with some pdfs though that the Unarchiver will not extract every image? I am thinking certain image types it is unable to extract.

  6. install xpdfreader (command line) and use pdftopng — https://www.xpdfreader.com/pdftopng-man.html

    1. Nice find, but that converts the whole page to a png file, but I had multiple images on each page and wanted to extract each distinct image (getting the original element without conversion quality loss).
      Related side tip: .docx (word) is a zip file, so changing that to .zip and you can easily extract the individual images and other elements.
      I don’t have a mac any more, and I’m not sure what the equivalent windows solution would be.

Leave a Reply

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

Search this site

Free apps

  • birthday.sroot.eu – Your birthday or other celebration date based on [years on other planets] / [how many seconds/days] / [how far you’ve travelled around the sun]
  • stampulator.sroot.eu – Calculates the combination and how many 1st, 2nd, large 1st and large 2nd class Royal Mail stamps you need on large envelopes and packets

Recent posts