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.

I'm writing a report and inserting a few raster images in (in PNG format) using:

\usepackage[pdftex]{graphicx}

\includegraphics[width=4in]{poker.png}

My problem is that when saving as a PDF the images are look really awful, am I missing something?

share|improve this question

migrated from stackoverflow.com Oct 12 '12 at 21:32

This question came from our site for professional and enthusiast programmers.

    
How big is the image originally? –  gnud Apr 15 '09 at 11:30
    
What kind of awful do they look like ? –  Damien Pollet Apr 18 '09 at 17:19
    
Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. –  Werner Oct 12 '12 at 22:56
    
Dude! I saw the .pdf you posted as a comment on Blackshift's answer. The image in the .pdf is of the same resolution as the original image (in the link you provided). And that I must say is not very high. The best option that you have, as Vartec has already answered, is to convert the .png to .eps - that way you can zoom as much as you want without affecting the resolution. –  Shashank Sawant Oct 13 '12 at 1:27

5 Answers 5

up vote 9 down vote accepted

I do the exact thing all the time, and it always looks good.

Perhaps it is the pdf viewer that renders it badly? (I use xpdf mostly.)

Maybe you can post screenshots of the image, and how it looks in the pdf document?

share|improve this answer
    
Here is the PDF: loljdawson.googlepages.com/LaTeX1.pdf And here is the source png: loljdawson.googlepages.com/poker.png Followed by the TEX: loljdawson.googlepages.com/LaTeX1.tex Thanks for the help :) –  user64392 Apr 15 '09 at 11:46
    
If I view the pdf at 100% (with xpdf), I can't visually distinguish the original image from the one in the pdf. Let me see whether I can post an image as well. –  BlackShift Apr 15 '09 at 11:50
    
    
Strange, looks O.K for you and good on my Macbook - but under Windows looks poop. Thanks for your help! –  user64392 Apr 15 '09 at 12:21
    
Well, the resolution is way too low for printing at this size on paper, but otherwise it looks like the png file here. –  Damien Pollet Apr 18 '09 at 17:22

The image file poker.png has a poor resolution. The cropped text has 90 × 56 pixels only. The resolution is 72 DPI, This is not suitable for printing unless it is scaled down.

The PDF specification knows a key Interpolation for bitmap images:

Image Interpolation

When the resolution of a source image is significantly lower than that of the output device, each source sample covers many device pixels. As a result, images can appear jaggy or blocky. These visual artifacts can be reduced by applying an image interpolation algorithm during rendering. Instead of painting all pixels covered by a source sample with the same color, image interpolation attempts to produce a smooth transition between adjacent sample values.

Image interpolation is enabled by setting the Interpolate entry in the image dictionary to true. It is disabled by default because it may increase the time required to render the image.

Note: The interpolation algorithm is implementation-dependent and is not specified by PDF. Image interpolation may not always be performed for some classes of images or on some output devices.

Driver pdtex.def supports it by option interpolate:

\includegraphics[interpolate]{poker.png}

It depends on the PDF viewer, whether this feature is implemented. Example for the image without interpolation:

Without interpolation

With interpolation:

With interpolation

A better variant is to replace the image by a vector graphics. The font seems to be Helvetica. The following example uses the clone TeX Gyre Heros:

\documentclass{standalone}
\usepackage{graphicx}
\usepackage{color}

\begin{document}
\scalebox{3}{%
  \setlength{\fboxsep}{2mm}%
  \colorbox{black}{%
    \textcolor{white}{%
      \usefont{T1}{qhv}{bx}{n}%
      \begin{tabular}{@{}c@{}}%
        P\kern-.15exO\kern-.18exK\kern-.175exE\kern-.21exR\\%
        F\kern-.35exA\kern-.25exC\kern-.2exE%
      \end{tabular}%
    }%
  }%
}
\end{document}

Result

share|improve this answer

Years ago I had similar problem. The solution was to use directly pdflatex, instead of latex and dvipdf.

Alternative was to convert PNG to EPS.

share|improve this answer

I've always had the same problem, but the print is always fine. The only solution I know is to use vectorial images, but it's not always possible.

To me the problem juste comes from the fact the PDF viewer scales the image badly. There are often strange things like this, for example some capitals look wrong with Adobe's viewer, but once it's printed the result is always fine.

(You don't need to put the .png extension in the file name: graphicx automatically looks for the image with that name which has the best quality.)

share|improve this answer
1  
After reading blackshift's answer, I've recompiled one of my documents without resizing the image (so no [width=...] parameter), and it actually works! (With xpdf, at 100%. With Evince it's still ugly.) –  Bastien Léonard Apr 15 '09 at 11:57

Are you viewing the PDF in original size? And is the image included in the document in it's original size? Resizing the image can result in awful images.

share|improve this answer
    
I'm using adobe pdf viewer, and viewing at 100%. –  user64392 Apr 15 '09 at 11:48

Your Answer

 
discard

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