Page 1 of 1

PDF to JPG – Trying to obtain a “Crisp” (not fuzzy) JPG

Posted: 2012-08-05T11:15:10-07:00
by BradM
All,

I am trying to convert a PDF file to a JPG file.

The conversion is working, but the generated JPG image is quite fuzzy.

I am using a “-quality 100” parameter.

Are there other ImageMagick parameters that I should be using to eliminate the fuzziness?

Thanks,
Brad

Re: PDF to JPG – Trying to obtain a “Crisp” (not fuzzy) JPG

Posted: 2012-08-05T11:30:58-07:00
by fmw42
use supersampling

convert -density 288 image.pdf -resize 25% -quality 100 image.jpg

PDF files have no real size and its size is defined by the -density. Nominal density is 72. So 288 =72*4. Thus we have to resize by 1/4 to get back to normal size afterwards. You also may not need -quality 100 if the supersampling helps. You might be able to lower the jpg quality and still be fine.

Re: PDF to JPG – Trying to obtain a “Crisp” (not fuzzy) JPG

Posted: 2012-08-05T12:10:35-07:00
by BradM
fmw42,

Thanks for the assistance. I really appreciate it.

The " -density 288" parameter did the trick.

I am all smiles.

Thanks again,

Brad

Re: PDF to JPG – Trying to obtain a “Crisp” (not fuzzy) JPG

Posted: 2012-08-07T01:00:10-07:00
by henrywho
To add even more acutance (sth like edge sharpness),

Code: Select all

convert -density 288 image.pdf -filter lagrange -distort resize 25% -quality 95 -sampling-factor 1:1 image.jpg
Linear RGB resize is mathematically more correct but this is probably counter-productive in this use case:

Code: Select all

convert -density 288 image.pdf -colorspace RGB -filter lagrange -distort resize 25% -colorspace sRGB -quality 95 -sampling-factor 1:1 image.jpg
BTW, If your PDF contains transparency, insert " -background white -alpha remove " after the pdf file name.

Re: PDF to JPG – Trying to obtain a “Crisp” (not fuzzy) JPG

Posted: 2012-08-07T05:28:12-07:00
by pipitas
fmw42 wrote:use supersampling
convert -density 288 image.pdf -resize 25% -quality 100 image.jpg
I ran

Code: Select all

convert  -density 288  http://qtrac.eu/boson1.pdf[1]  -scale 25% boson2-supersampled.jpg
and the output is almost all black (apart from 2 spots).

If I let go the scale step, running this:

Code: Select all

convert  -density 288  http://qtrac.eu/boson1.pdf[1]  boson2-400pc.jpg
the output is OK.

Could this be a general ImageMagick bug?! Or could this come from enabling OpenCL and/or HDRI?

My IM version is:

Code: Select all

Version: ImageMagick 6.7.8-3 2012-07-30 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features:  OpenCL HDRI


Also, using PNG instead of JPEG does look better: but there are still 1 (smaller) issue with it:
  • * The output PNGs show a gray background. (The original PDF page has a transparent background).

Re: PDF to JPG – Trying to obtain a “Crisp” (not fuzzy) JPG

Posted: 2012-08-07T05:34:36-07:00
by pipitas
pipitas wrote:
fmw42 wrote:use supersampling
convert -density 288 image.pdf -resize 25% -quality 100 image.jpg
I ran

Code: Select all

convert  -density 288  http://qtrac.eu/boson1.pdf[1]  -scale 25% boson2-supersampled.jpg
and the output is almost all black (apart from 2 spots).
Ahhh... thanks to henrywho's hint I added -background white -alpha remove behind the PDF name and then it worked as expected:

Code: Select all

convert  -density 288  http://qtrac.eu/boson1.pdf[1]  -background white  -alpha remove  -scale 25% boson2-supersampled.jpg
No more black page!

:)

Re: PDF to JPG – Trying to obtain a “Crisp” (not fuzzy) JPG

Posted: 2012-08-07T10:06:43-07:00
by fmw42
You will get better quality though slower by using -resize rather than -scale