5

I'm using pdfimages to extract images from a PDF File. I've counted at last 10 images. But the program will only extract 4.

pdfimages -all file.pdf i

Generates

-rw-rw-r--    1 victor victor   61389 Jul 14 21:48 i-000.png
-rw-rw-r--    1 victor victor      88 Jul 14 21:48 i-001.png
-rw-rw-r--    1 victor victor    5226 Jul 14 21:48 i-002.png
-rw-rw-r--    1 victor victor   95657 Jul 14 21:48 i-003.png

Am I missing some setting?

How can I extract all images?

  • My version of pdfimages allows this parameter... " -all : equivalent to -png -tiff -j -jp2 -jbig2 -ccitt" – Victor Ribeiro Jul 15 '16 at 01:19
  • 5
    How do you know that the PDF has more than 4 images? `pdfimages` only retrieve raster images, vector based images (e.g. eps) are not touched by `pdfimages`. – grochmal Jul 15 '16 at 02:02

3 Answers3

5

Pdfimages only supports raster images. What you are seeing in your PDF is most likely a vector graphic.

I don't think there is a way to extract them automatically but you can use tools like Inkscape or LibreOffice Draw to get such a graphic manually. The process is the same for both:

  1. Open the PDF
  2. Select the area of the graphic
  3. Copy to clipboard (Ctrl + C)
  4. Get a new document (Ctrl + N)
  5. Paste (Ctrl + V)
  6. Move to top left and adjust page size (Inkscape can automate both: Ctrl+Shift+R)
  7. Draw: Export / Inkscape: Save as (Ctrl+Shift+S)
dreua
  • 258
  • 2
  • 10
0

Don't have the rep to upvote, but my answer is same as answered above for Inkscape, except recommend to use the File->Export PNG Image... option to specify the image resolution. For my case of an eps graphic of a paper map (3'by3' in hardcopy), I imported to Inkscape at quality factor of 30, and output at 5000x5000 to get a good result. Whereas I think Ctrl-Shift-S by default is fairly low resolution. My particular case also crashed out LibreOffice pretty harshly, which was unexpected. The current LibreOffice is otherwise very good software in my experience.

J B
  • 101
  • 1
  • 1
    This does not provide an answer to the question. Once you have sufficient [reputation](https://unix.stackexchange.com/help/whats-reputation) you will be able to [comment on any post](https://unix.stackexchange.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/426430) – Toby Speight Oct 20 '22 at 16:05
0

I also have a suggestion: there is this online tool from Semadox: https://www.semadox.com/pdf-image-extraction . There you can extract the images in original resolution.

Disclaimer: I am the founder of Semadox, but the tool is for free and will always stay free.

uphill
  • 101
  • 1