Imagemagick: Rasterize the PDF to a set resolution when reading it in
imagemagick, pdf
Solution
This is not possible with the current version of ImageMagick (6.8.8-7). We found your post here and added the following feature that will be available in ImageMagick (6.8.8-8):
You can scale a PDF to a width of 548 pixels with the following command:
$ convert -define psd:fit-page=548x input.pdf thumbnail.png
If you create an image with another DPI than the default (72 DPI) you will have to resize it afterwards:
$ convert -density 300 -define psd:fit-page=548x input.pdf -resize 548x thumbnail.png
Problem
I want to generate thumbnails of PDFs at a fixed width (548px wide, with the height determined by the PDF page aspect ratio). With ImageMagick, I can do this with the command: ``` $ convert -density 300 -resize 548x input.pdf thumbnail.png ``` This works for arbitrary sized PDFs, however, the larger the PDF the longer it takes. From the documentation I understand that this is because ImageMagick first has to read in the PDF and rasterize it (at 300 DPI), before scaling it down. This obviously takes longer and more memory the larger the PDF is. My question is: Can we tell ImageMagick to rasterize the PDF to a set resolution when reading it in (something like 2 or 3 times larger than the thumbnail needs to be) before scaling it down and outputting the PDF? This should allow our conversion to run in roughly the same amount of time regardless of the PDF size. We can do this ourselves manually by reading the PDF resolution first and then calculating the appropriate DPI to generate a rasterized PDF of the right size, but this seems like a bit of a hack and I would expect something like this built into ImageMagick.