Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

imagemagick - generated PDFs are blurry/hazy

I have an image of a website which I'm trying to convert to PDF. I have the image in several formats: PSD, PNG, JPG, TIFF, all saved losslessly.

I'm using the following command to convert the image to PDF:

convert -density 93 foo.jpg bar.pdf

Here is part of the original image:

Original

And here is the same part, after converting to PDF:

Converted

As you can see, the second one is ever so slightly hazy. What's causing this, and how can I eliminate it? I've seen PDFs with crisp graphics, so I know it's possible.

like image 388
Brian Gradin Avatar asked Nov 15 '25 05:11

Brian Gradin


1 Answers

If you are seeing the same results with multiple input types. The fuzziness is likely being caused by the anti-aliasing feature of your PDF Viewer. If using Acrobat, you can turn off image anti-aliasing by doing the following:

Go to Edit-->Preferences-->Page Display

Untick the option "Smooth Images" and hit "OK".

The crisp graphics you are seeing on other PDFs are likely due to the fact that they are vectorized graphics. Imagemagick is creating a PDF and embedding your image inside of it which may be subject to compression.

Also:

When using jpeg as input, add the "-quality 100" to your Imagemagick call to retain the highest quality possible.

Use a higher value for the "-density" parameter (I would recommend at least 150) to generate a higher resolution PDF.

like image 59
Arnulfo Arroyo Avatar answered Nov 17 '25 21:11

Arnulfo Arroyo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!