What is the actual resolution of your PNG? Is it around 100 dots per inch, or at least 600? The former looks fine on screen but will be horribly pixellated unless it is printed extremely small, the latter is needed for typeset text.
–
András SalamonAug 5 '10 at 18:10

2

pdfTeX does not alter images. Perhaps post the problematic file somewhere we can get at?
–
Joseph Wright♦Aug 5 '10 at 18:13

This question seems to be about a specific case, rather than a general issue. However, I can see what you mean.
–
Joseph Wright♦Aug 5 '10 at 18:17

@András: the PNG is 94dpi. Indeed, for printing is not enough, but the chart looks a bit blurry on the screen as well. I will read the other thread (which is quite informative) and try again tonight.
–
wishihadabetternameAug 5 '10 at 18:35

7 Answers
7

A 94dpi PNG figure included in a PDF file will certainly look blurry on screen.

Most likely your PDF viewer doesn't show your document so that 1 pixel in the PNG file corresponds to 1 pixel on screen. Even if you manage to find exactly the right zoom level, the origin of the PNG file is not necessarily aligned with screen pixels. Some kind of interpolation is done in virtually any situation if you have PNG (or JPEG) figures in PDF files.

How to do it correctly:

Use vector graphics for line drawings.

Use high-resolution JPEG files for photos. Something like 300 dpi is usually enough; looks good on screen and when printed. There is always some scaling and interpolation involved when displayed on screen, but in practice you don't really see any softness in photos.

If you have a line drawing and if you really must use raster files instead of vector graphics, then use very high-resolution PNG files. Something like 600 dpi is usually enough. It looks good when printed. It will look reasonably good on screen; there will be some softness, e.g. horizontal and vertical lines are not as sharp as you would like, but you can usually live with this solution fairly well.

Is JPEG "better" than PNG or why do you recommend using JPEG for photos? Do you recommend PNG for rastered vector graphics as it has a lossless compression (in contrast to JPEG which looses some image information each time you save it, AFAIK)?
–
MostlyHarmlessMay 20 '11 at 7:48

3

@Martin: JPEG (with an appropriate compression level) is good enough for photos, and you get a reasonably small file size even if you have a high resolution (saving a 300dpi photo as a PNG would be huge). Lossy JPEG compression is not good enough for line drawings, but fortunately you don't need it, either (rasterised vector graphics are easy to compress losslessly; a 600dpi version of a black-and-white line drawing is a surprisingly small PNG file).
–
Jukka SuomelaMay 20 '11 at 8:42

Yes, the fact that your image is 94 dpi essentially guarantees that it will appear blurry on screen virtually everywhere.

The reason for this is that it's in the ballpark of the resolutions that computers are typically configured to pretend the screen has, but doesn't actually match any of them; the most popular such resolutions seem to be/have been 72, 96, and 120 dpi: these were convenient for desktop publishing because they give pixel:bp ratios of 1:1, 4:3, and 5:3. The most common resolution claimed by PNGs seems to be 96 dpi, and so they can be displayed 1:1 on systems pretending any of these resolutions using reasonably simple zoom levels in the PDF viewer: 133.3...%, 100%, and 80%, respectively. (Assuming, of course, that the PDF viewer is pretending the same resolution as the rest of the system; Acrobat [Reader] in particular has a setting for this.)

96 and 94 dpi are just too close for decent upsampling, in any case; I'm not sure how to argue this mathematically, but, well, just try it if you don't believe me ;-).

I would suggest overriding/editing the value in the image header with 96 dpi, since that will at least display nicely in many places, though unfortunately not nearly all of them: the computers at my college, for example, had Acrobat Reader set to use 110 dpi. (Well, still have, presumably—I've graduated, though, so it seems like I ought to use the past tense...)

Note on TeX Units of Distance

For those unfamiliar with the designation "bp", I give you this line from p. 57 of the TeXbook:

bp big point (72 bp = 1 in)

They are called "big points" rather than just "points" because Knuth preferred to stay closer to the official definition of the point. From p. 58:

The units have been defined here so that precise conversion to sp is efficient on a wide variety of machines. In order to achieve this, TeX’s “pt” has been made slightly larger than the official printer’s point, which was defined to equal exactly .013837 in by the American Typefounders Association in 1886 [cf. National Bureau of Standards Circular 570 (1956)]. In fact, one classical point is exactly .99999999pt, so the “error” is essentially one part in 108. This is more than two orders of magnitude less than the amount by which the inch itself changed during 1959, when it shrank to 2.54 cm from its former value of (1/0.3937) cm; so there is no point in worrying about the difference. The new definition 72.27 pt = 1 in is not only better for calculation, it is also easier to remember.

I'm using PNG files without DPI information (at least Irfan View shows blank fields for DPI), on paper they appear as it should, and Foxit blurs them at 100% but they are looking ok at 150% (at that zoom level they appear on screen at the same size as shown in Irfan View).
The figures are inserted with \includegraphics[scale=0.5]{images/fig1} (the original size is 716x461 pixels)

Funny, this was exactly my case (they look good with scale = 0.5). It must be a display interpolation issue as the others indicated, so I'll use vector graphics in the future.
–
wishihadabetternameAug 6 '10 at 15:50

Just to have this up here for reference: I notice sometimes that my pdf viewer tries to antialias raster images in my tex-created pdf documents. This also makes the images look blurry. Normally you should be able to disable antialiasing in the viewer's settings, yet this also makes the pdf text (which should be aliased) look ugly. This only affects the on-screen appearance and will have no effect (as far as I know) on the printed document.

Note that it's possible to turn on an interpolation key when generating PostScript which will be persistent into a .pdf and influence who its rendered (unless it's stripped out).
–
WillAdamsSep 18 '13 at 16:48