I need to render or fetch all the images from a specific PDF file. How can I achieve this using Ghostscript or ImageMagick ?
You cannot do it with Ghostscript, but you can do it with Poppler's or XPDF's commandline tools named pdfimages
:
pdfimages -j some.pdf subdir/image-prefix
All the images will now be located in subdir/
named image-prefix-0001.jpg
, image-prefix-0002.jpg
...
The -j
parameter will make the command try to directly extract JPEGs. Failing to create JPEGs, it will create PNMs or PPMs, which you can always convert using ImageMagick:
convert subdir/image-prefix-0033.ppm subdir/image-prefix-0033.jpeg