Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This is a follow-up to Included png appears too big in PDF, but it's a separate issue so I'll put it in its own question instead of burying it in comments.

The problem: an included PNG, included without scaling, appears blurry in the PDF, as if the PDF has run it through a lossy compression.

I have tried multiple times with different values for either \pdfimageresolution or \includegraphics[width=...,height=...] added to the source below but no luck.

Is there any way I can check log compresses the image as it appears to do?

And to be thorough, I'm looking at the PDF in Foxit 3.2 at 1:1 zoom.

\documentclass[12pt]{article}
\usepackage[letterpaper]{geometry}
\geometry{top=1.0in, bottom=1.0in, left=1.5in, right=1.0in}
\usepackage{graphicx}
\begin{figure}
  \includegraphics{chart}\\                            % line 35 
  \caption{Adjusted Relative Risk (RR)}\label{mylabel} % line 36
\end{figure}

Log is:

Command Line:   texify.exe --pdf --tex-option=--synctex=-1 "C:\Documents and Settings\myself\Application Data\WinEdt Team\WinEdt 6\RW\test1.tex"
Startup Folder: C:\Documents and Settings\myself\Application Data\WinEdt Team\WinEdt 6\RW

This is pdfTeX, Version 3.1415926-1.40.10 (MiKTeX 2.8)
entering extended mode

("C:/Documents and Settings/myself/Application Data/WinEdt Team/WinEdt 6/RW/t
est1.tex"
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, dumylang, nohyphenation, ge
rman, ngerman, german-x-2009-06-19, ngerman-x-2009-06-19, french, loaded.
(C:\MiKTeX\tex\latex\base\article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(C:\MiKTeX\tex\latex\base\size12.clo)) (C:\MiKTeX\tex\generic\babel\babel.sty
*************************************
* Local config file bblopts.cfg used
*
(C:\MiKTeX\tex\latex\00miktex\bblopts.cfg)
(C:\MiKTeX\tex\generic\babel\english.ldf (C:\MiKTeX\tex\generic\babel\babel.def
))) (C:\MiKTeX\tex\latex\graphics\graphicx.sty
(C:\MiKTeX\tex\latex\graphics\keyval.sty)
(C:\MiKTeX\tex\latex\graphics\graphics.sty
(C:\MiKTeX\tex\latex\graphics\trig.sty)
(C:\MiKTeX\tex\latex\00miktex\graphics.cfg)
(C:\MiKTeX\tex\latex\pdftex-def\pdftex.def)))
(C:\MiKTeX\tex\latex\geometry\geometry.sty
(C:\MiKTeX\tex\generic\oberdiek\ifpdf.sty)
(C:\MiKTeX\tex\generic\oberdiek\ifvtex.sty)
(C:\MiKTeX\tex\latex\geometry\geometry.cfg))
(C:\MiKTeX\tex\latex\base\flafter.sty)
(C:\MiKTeX\tex\latex\setspace\setspace.sty
Package: `setspace' 6.7 <2000/12/01>
)
("C:\Documents and Settings\myself\Application Data\WinEdt Team\WinEdt 6\RW\t
est1.aux") (C:\MiKTeX\tex\context\base\supp-pdf.tex
[Loading MPS to PDF converter (version 2006.09.02).]
)
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
[1{C:/MiKTeX/pdftex/config/pdftex.map}] [2]
<chart.png, id=15, 362.11884pt x 257.55798pt> <use chart.png>
Underfull \hbox (badness 10000) in paragraph at lines 37--38

[3] [4 <C:/Documents and Settings/myself/Application Data/WinEdt Team/WinEdt 
6/RW/chart.png (PNG copy)>]
("C:\Documents and Settings\myself\Application Data\WinEdt Team\WinEdt 6\RW\t
est1.aux") )
(see the transcript file for additional information)<C:/MiKTeX/fonts/type1/publ
ic/amsfonts/cm/cmbx12.pfb><C:/MiKTeX/fonts/type1/public/amsfonts/cm/cmr10.pfb><
C:/MiKTeX/fonts/type1/public/amsfonts/cm/cmr12.pfb><C:/MiKTeX/fonts/type1/publi
c/amsfonts/cm/cmr17.pfb><C:/MiKTeX/fonts/type1/public/amsfonts/cm/cmr7.pfb><C:/
MiKTeX/fonts/type1/public/amsfonts/cm/cmr8.pfb><C:/MiKTeX/fonts/type1/public/am
sfonts/cm/cmti10.pfb>
Output written on test1.pdf (4 pages, 100135 bytes).
SyncTeX written on test1.synctex
Transcript written on test1.log.

Clarification: The blurriness is visible on-screen when looking at the PDF at 1:1 zoom. I haven't printed it.

share|improve this question
    
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 Salamon Aug 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
    
Appears to be duplicate of tex.stackexchange.com/questions/165/… which has been discussed at length. –  András Salamon Aug 5 '10 at 18:16
    
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. –  wishihadabettername Aug 5 '10 at 18:35
add comment

7 Answers

up vote 41 down vote accepted

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.

share|improve this answer
3  
Thanks, I will use vector graphics. –  wishihadabettername Aug 6 '10 at 15:48
    
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)? –  Martin May 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 Suomela May 20 '11 at 8:42
add comment

You could try png2pdf or a similar tool. Check the result with it, perhaps specify interpolation to be off. Interpolation might cause the image to look blurry.

share|improve this answer
add comment

This bit of the log:

6/RW/chart.png (PNG copy)>]

Explicitly notes that the PNG file is included as-is. Any issues with the display quality are therefore either caused by the previewer you use, or by the PNG image itself.

share|improve this answer
2  
a vote up for explaining that log detail. Thanks. –  wishihadabettername Aug 6 '10 at 15:49
add comment

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)

share|improve this answer
    
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. –  wishihadabettername Aug 6 '10 at 15:50
add comment

I had similar problems, but found I could resolve them by increasing the resolution of the generated PDF:

\setlength{\pdfpxdimen}{1in/150} % Define resolution of PDF

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
    
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). –  WillAdams Sep 18 '13 at 16:48
add comment

Your Answer

 
discard

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.