Page 1 of 1

[resolved, thanks!] loss of resolution converting PDF to PNG

Posted: 2014-05-02T10:42:30-07:00
by traq
I have a PDF which I am trying to convert to PNG. The PDF is 35.46" × 17.24" at 400dpi, but when I convert to PNG, the output image is only 2553px × 1241px (I'm expecting more like 14184×6896).
I was able to use the -resize option to get the expected dimensions, but it is just an enlarged version of the smaller converted image.

Comparison (original PDF on the left; converted (enlarged) PNG on the right):
Image

I'm a fairly new ImageMagick user, so I'm sure this is just something I'm not specifying correctly. I'm using version 6.7.7-10 2013-02-25 Q16 from the cli on Linux Mint.

Some commands I've tried so far:

Code: Select all

convert -colors 540000 <pdf file name> <png file name>
convert -colors 540000 -size 14184x6896 <pdf file name> <png file name>
convert <pdf file name> -colors 540000 -size 14184x6896 <png file name>
convert <pdf file name> -colors 540000 -resize 14184x6896 <png file name>
Any ideas?

Re: severe loss of resolution converting from PDF to PNG

Posted: 2014-05-02T10:47:22-07:00
by snibgo
traq wrote:The PDF is 35.46" × 17.24" at 400dpi ...
You need to tell ImageMagick this, with "-density 400". (Not with "-size".)

Re: severe loss of resolution converting from PDF to PNG

Posted: 2014-05-02T10:52:00-07:00
by traq
snibgo wrote:
traq wrote:The PDF is 35.46" × 17.24" at 400dpi ...
You need to tell ImageMagick this, with "-density 400". (Not with "-size".)
So,

Code: Select all

convert <pdf file name> -colors 540000 -density 400 <png file name>
?
(I am trying this out for myself; I just wanted to double-check since it's been taking about an hour for IM to finish.)

Thanks!

Re: severe loss of resolution converting from PDF to PNG

Posted: 2014-05-02T10:59:14-07:00
by snibgo
"-density" tells Ghostscript what resolution to use, so it needs to come before the pdf file name.

Re: severe loss of resolution converting from PDF to PNG

Posted: 2014-05-02T11:35:53-07:00
by traq
alright, thanks!

Re: severe loss of resolution converting from PDF to PNG

Posted: 2014-05-02T11:41:45-07:00
by fmw42
You can also specify a larger density than 400 and then resize the image down to the right size. That will give higher quality but will take longer to process.

Re: severe loss of resolution converting from PDF to PNG

Posted: 2014-05-02T11:50:36-07:00
by traq
fmw42 wrote:You can also specify a larger density than 400 and then resize the image down to the right size. That will give higher quality …
Even though the original is only 400dpi?

edit: the -density option worked perfectly. Thanks so much!

Re: [resolved, thanks!] loss of resolution converting PDF to

Posted: 2014-05-02T12:47:02-07:00
by fmw42
you could do

Code: Select all

convert -density 800 image.pdf -resize 50% image.png
That would make the intermediate image twice the dimensions you need, but then resize it down by 50% to the size you wanted. This is not need, but just an option.

or

Code: Select all

convert -density XX image.pdf -resize 14184×6896 image.png
where XX is >400

Re: [resolved, thanks!] loss of resolution converting PDF to

Posted: 2014-05-02T13:30:43-07:00
by traq
fmw42 wrote:

Code: Select all

convert -density 800 image.pdf -resize 50% image.png
That would make the intermediate image twice the dimensions you need, but then resize it down by 50% to the size you wanted. This is not need, but just an option.
Got it. I was just wondering if doing that would give any benefit, seeing as the original is only 400dpi…?

Re: [resolved, thanks!] loss of resolution converting PDF to

Posted: 2014-05-02T13:46:40-07:00
by fmw42
It might give slightly better quality. But you should test and make that determination.