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
PDF to JPG – Trying to obtain a “Crisp” (not fuzzy) JPG
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PDF to JPG – Trying to obtain a “Crisp” (not fuzzy) JPG
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.
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
fmw42,
Thanks for the assistance. I really appreciate it.
The " -density 288" parameter did the trick.
I am all smiles.
Thanks again,
Brad
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
To add even more acutance (sth like edge sharpness),
Linear RGB resize is mathematically more correct but this is probably counter-productive in this use case:
BTW, If your PDF contains transparency, insert " -background white -alpha remove " after the pdf file name.
Code: Select all
convert -density 288 image.pdf -filter lagrange -distort resize 25% -quality 95 -sampling-factor 1:1 image.jpg
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
Last edited by henrywho on 2012-08-07T17:05:42-07:00, edited 1 time in total.
Re: PDF to JPG – Trying to obtain a “Crisp” (not fuzzy) JPG
I ranfmw42 wrote:use supersampling
convert -density 288 image.pdf -resize 25% -quality 100 image.jpg
Code: Select all
convert -density 288 http://qtrac.eu/boson1.pdf[1] -scale 25% boson2-supersampled.jpg
If I let go the scale step, running this:
Code: Select all
convert -density 288 http://qtrac.eu/boson1.pdf[1] boson2-400pc.jpg
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
Ahhh... thanks to henrywho's hint I added -background white -alpha remove behind the PDF name and then it worked as expected:pipitas wrote:I ranfmw42 wrote:use supersampling
convert -density 288 image.pdf -resize 25% -quality 100 image.jpgand the output is almost all black (apart from 2 spots).Code: Select all
convert -density 288 http://qtrac.eu/boson1.pdf[1] -scale 25% boson2-supersampled.jpg
Code: Select all
convert -density 288 http://qtrac.eu/boson1.pdf[1] -background white -alpha remove -scale 25% boson2-supersampled.jpg

- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PDF to JPG – Trying to obtain a “Crisp” (not fuzzy) JPG
You will get better quality though slower by using -resize rather than -scale