Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

There are a lot of questions out there about how to convert a PDF file to a PNG image, but I'm looking to take a nice sharp PNG file and just basically wrap it or embed it in a PDF file without having it look blurry or fuzzy.

I realize with imagemagic installed I can do a simple conversion like:

convert sample.png sample.pdf

I've also tried a lot of the switches to set the depth, and also the quality setting:

convert -quality 100 sample.png sample.pdf

However the PDF still comes out looking blurry / fuzzy.

Here's a sample image:

As a png it's crisp and clean. When I convert it to a PDF, even at the same size it looks blurry:

Picture 4.png

How can I convert PNG to a PDF in high quality?

share|improve this question
I hope you find a good answer to your question, but I think it is just a given property of PDF to store images in JPG format. PNG, like the one you show us, has much better quality than JPG. –  jippie Jul 12 '12 at 6:32
@cwd: Did you try to put it in a .tex file, and then generate the PDF? With \usepackage[pdftex, final]{graphicx} and \includegraphics[width=516px]{calendar.png}, for example. –  Emanuel Berg Jul 13 '12 at 8:17
@jippie: No, PDF can store bitmaps losslessly. The link gives a list of compression algorithms rather than formats, because the bitmap data inside a PDF can't be extracted and viewed directly as a JPEG or TIFF, but you wouldn't go far wrong saying that PDF images are either JPEG (lossy), JPEG 2000 (also lossy) or any of several TIFF variants (lossless). What is true, however, is that a given PDF distiller may default to translating bitmaps into DCT (a.k.a. JPEG) form, and have to be told to use a lossless form instead. –  Warren Young Jul 13 '12 at 9:38

4 Answers 4

I think that for png-to-pdf -density parameter should small rather than large. You could try something like convert -quality 100 -density 50

share|improve this answer
Nope higher density is definitely better, just did a test, 50 results in lots of very visible pixels, 300 is nice and crisp looking. –  shaunhusain Sep 28 '14 at 23:13
This has been confusing me, but I think a higher density results in output with lower resolution. That means that if the output is fuzzy (over-aliased, like the example in the original question) then lower density is what you want. But if a PDF is pixelated then indeed you need to convert with a higher density. –  Brian Z Apr 22 at 7:32

Try using the -density option. The default resolution is 72 dots per inch. So try something like -density 300.

For reference see -density in the ImageMagick command-line options documentation.

share|improve this answer
awesome! Thanks! –  Gabriel Samfira Jan 13 '14 at 9:47
Density definitely seems to be the key. Scale and density seem to be inversely related, so I have been playing with both settings to get an optimum result in terms of both appearance and file size... If there is a set formula, I wish I knew it. –  Brian Z May 2 at 4:18

PDF is a vector format (i.e., the file contains a description of lines to draw), while other formats (JPG, PNG) are raster formats (the file describes what color to paint each pixel). If you blow a PDF up, it is still just sharp lines; JPG and PNG show the pixelation.

(OK, OK, I lied. A PDF can also be a raster).

share|improve this answer

I am almost certain that what you perceive as a loss of quality in the PDF, is just an effect of your PDF viewer's anti-aliasing feature.

If you use evince to view the PDF, you can see the anti-aliasing feature automatically switched off at a certain zoom (300% in my quick test). You can see that vividly when you keep zooming in - you will notice that at some point, pixels become suddenly clearly visible. That is the point when anti-aliasing must have been switched off to allow precise image inspection.

share|improve this answer
Hmm - that makes sense but I guess I was hoping to be able to somehow set the image and the "initial view" to 100% so that it looks crisper. –  cwd Jul 12 '12 at 20:10
@cwd Don't mistake the zoom (a way of examining the file) with the actual cause of image smoothing: anti-aliasing. The image is stored properly. It is the PDF viewer that fools you. But it could be the other way around even - if you'd take some other viewing applications or change their settings. You could then see a sharp image in a PDF file and a smoothed PNG file in an image viewer. –  rozcietrzewiacz Jul 13 '12 at 6:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.