ImageMagick command line: converting PDF to high definition images

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Posts: 2
Joined: 2018-11-05T00:49:38-07:00
Authentication code: 1152

ImageMagick command line: converting PDF to high definition images

Post by tutu11 » 2018-11-05T00:54:44-07:00

I'm trying to convert a PDF file to images on the fly using imagemagick from command line. These PDFs are in very high definition and I would like to get correlated images (JPG).

Usually used Gimp, when I convert these PDF to 600dpi under this software the quality is super top. But I do not see myself convert more than 500 images one by one with Gimp ... that's why I turn to ImageMagick, especially since converting image files on the fly happens to me more and more often, I would like to master this type of tool.

Alas, with ImageMagick, by default I get very small images (type 468x705), despite the setting of a density at 600dpi:

convert *.pdf -density 600 -quality 100 *.jpg
So I added a resize command (I also tried scale), the image is much higher definition (type 4680x7050), but is pixelated as if I had remained at the default definition:

convert *.pdf -resize 1000% -density 600 -quality 100 *.jpg
I even thought it could come from the order of orders, but that does not change anything:

convert *.pdf -density 600 -resize 1000% -quality 100 *.jpg
An idea ?

Subsidiary (but less crucial) question: how to keep the same name for the destination file as the original one?

EDIT : In addition to the for loop proposed by Mark Setchell I just discovered that you can use mogrify. Example:

mogrify -format jpg -density 600 -blur 1x1 -quality 100 *.pdf ... ile/129873

Posts: 10929
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: ImageMagick command line: converting PDF to high definition images

Post by snibgo » 2018-11-05T02:08:00-07:00

tutu11 wrote:convert *.pdf -density 600 -quality 100 *.jpg
"-density" is a setting for reading PDFs, so put it before the inputs.

That command will read all the input PDFs into memory, then write to files called something like "*-0.jpg". I suggest you either (a) use convert one PDF at a time, inside a shell loop, or (b) use mogrify.
snibgo's IM pages:

Post Reply