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 have a .png screenshot and I want to insert it in a LyX document.

alt text

However, the screenshot needs scaling to fit in my column width. Downscaling (or upscaling) the image, if done wrong, gives all kinds of bad, unprofessional results.

How do you embed screenshots properly? Is there a way to change the interpolation mode, or disable it altogether (and does it acually help)?

share|improve this question
    
Yes, I know about this question, but I'm not looking for a way to make a vector image out of my png image, as it wouldn't make sense here. –  badp Oct 22 '10 at 19:49
    
See also Included PNG appears blurry in PDF. –  Jukka Suomela Oct 22 '10 at 20:20

5 Answers 5

up vote 13 down vote accepted

As the other answers have already made clear, a pixmap graphics is, in general, not very well scalable: You just can't get more "senseful" pixels.

Nevertheless, despite their much lower resolution, screen shots can look relatively well (that is, readable) on the printout, if prepared accordingly. The following is a somewhat loose list of recommendations that work for me:

  1. Take the screen shot at the maximum possible resolution. For screen shots of dialog windows, as in your case, it is often a good idea to increase the standard font size in the system settings, so that the pixmap of the dialog window becomes actually bigger.
  2. Always use a lossless file format for your screen shots, such as GIF or PNG (the latter being natively supported by pdflatex). Never, ever use JPG for a screen shot!
  3. Scale the image only by whole number factors (reciprocals of whole numbers if scaling down). If scaling by a factor of 2, for instance, the scaling algorithm can just double each discrete pixel, so the overall appearance remains the same. If, however, you scale by a factor of 1.1, the algorithm has to somehow make up 11 pixels out of ten, which leads to a blurred appearance.

    A consequence is: Do not scale to \columnwidh or \textwidth, as it would be pure coincidence if that results in a whole number scaling factor. Typeset the image centered and then scale it by factors of 2,3,4,... until you get something that "almost fills" the available space.

  4. If, for whatever reason, you have to scale by a rational number: Do not let pdflatex do it; use a good imaging software instead. If you scale by rational factors, the quality of the result depends a lot on the scaling algorithm, which has to take the kind and structure of the image into account. It has to work differently for photos than for screen shots. The algorithm used by pdflatex seems to be optimized for photo scaling.

share|improve this answer
2  
With pdflatex, a PNG is included as is into the PDF file. Any rescaling transformations are made by PDF viewer or printer (and depend of the resolution of the final device). So, IMHO, your two last items are unnecessary. –  Paul Gaborit Oct 23 '13 at 9:11

Just use pdflatex and \includegraphics with an appropriate scaling parameter. That's all.

You can't get anything better than this: your final PDF file will include the original PNG file as is, and the PDF viewer will do its best to scale it appropriately for screen and printer (depending on screen resolution, zoom settings, etc.).

It will look a bit fuzzy on screen in almost all cases, and it is unavoidable (regardless of whether you use a scaling parameter in \includegraphics or not). You can't force the user to choose a zoom level that happens to map 1 pixel in your screenshot to 1 pixel on screen. The whole point of a PDF file is that users can scale it arbitrarily when reading on screen.

share|improve this answer
    
If I upscaled the image by 5× with no interpolation at all, would the output improve on print and screen however? It doesn't seem to change at all on Evince (I have set the image to be 100% of a column width). –  badp Oct 22 '10 at 23:13
2  
@badp: No, upscaling won't help. You can't add information that isn't already there! –  Will Robertson Oct 23 '10 at 2:51
    
@badp: I do not recommend upscaling; for starters, reading your document might require a lot more resources (memory, CPU). That said, I have to admit that upscaling might help as a workaround with some PDF viewers in some special cases, as different PDF readers use different algorithms when they are forced to upscale low-resolution bitmaps: typically Adobe Reader is happy to show you individual pixels as sharp boxes (good for screenshots?) while many other readers try to produce "smooth" results (good for photos). –  Jukka Suomela Oct 23 '10 at 9:25

Just for the completeness: It is possible to take vector screenshots (pdf and svg) of gtk3 applications, see the project home https://gitorious.org/gtk-vector-screenshot and the demonstrating screencast http://www.joachim-breitner.de/various/pdf_screenshot_3.ogv.

share|improve this answer

Image interpolation is a feature implemented in Adobe Reader. Quotation from the PDF reference:

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.

This feature has to be enabled explicitly, though:

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.

The current pdftex.def in TeXLive supports this feature:

\includegraphics[interpolate]{nvak3}

It may, however, be a matter of taste whether the result is an improvement or not.

share|improve this answer

Downscaling should not be a problem. In fact, if it's a screen shot, you probably wouldn't want to downscale at all unless you have a monster screen resolution. I would scale your png in photoshop or gimp, select the interpolation type from image manipulation program, and then include the png as one normally would in latex.

share|improve this answer
4  
I would definitely not downscale the PNG file in any image manipulation program. I would simply include the original PNG file (with an appropriate scaling parameter). Then your final PDF file contains the full-resolution screenshot, it will look good (or at least as good as possible) when printed, and you can use a PDF viewer to zoom it on screen. –  Jukka Suomela Oct 22 '10 at 20:11

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.