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.

The TikZ & PGF manual says that ‘LaTeX’s \includegraphics is designed better than pgf’s image mechanism’ and that ‘LaTeX users are encouraged to use \includegraphics to include images.’ But is there any advantage of using \includegraphics instead of \pgfimage when not using any of the features exclusive to \includegraphics (such as clipping)?

The only differences I’ve found is that latexmk automatically recognises modified images when \includegraphics is used, but not when \pgfimage is used. On the other hand, \pgfimage supports the interpolate option, which is nice (though not widely supported in PDF readers). \pgfimage also supports masking, which \includegraphics does not. One last difference I’ve found is that \pgfimage only issues a warning, not an error, when a referenced image is not found. This may of course be both positive and negative; personally, I like it.

Are there any other important differences and advantages of using \includegraphics over \pgfimage?

share|improve this question
    
Have a look at answers and comments here: How can/should I include annotated images?. –  Stefan Kottwitz Oct 28 '11 at 16:15

1 Answer 1

up vote 18 down vote accepted

\pgfimage currently uses \includegraphics internally for every output format (i.e. driver) except for pdftex where it uses its own pdftex primitives to include the image (which are also used in \includegraphics BTW). A notable difference is that PGF provides different macros to declare the image first and then use it multiple times, while \includegraphics doesn't, nevertheless \includegraphics will also only store the image once in the PDF.

Note that since 2010/09/09 the pdftex driver for graphicx has supported the interpolate option. This isn't mentioned in the graphicx manual which seems to be frozen. I found it in the source file comments:

% 2010/09/09 v0.05a (HO)
% [..]
%  * Option `interpolate' added for bitmaps, see PDF specification.
%    Values are `true' or `false', default is `false'.

So you can use it as:

\includegraphics[interpolate=true]{<image>}
% or simply
\includegraphics[interpolate]{<image>}

Also a very big difference (IMHO) is that \includegraphics can use most of the new keys provided by my adjustbox package as long it is loaded with the export option. It provides frames, min/max sizes, multiple clippings, size adjustments, and more.

In summary, I think what is meant by the notice that "\includegraphics is designed better", is that it comes already with all needed drivers which are stable and tested through decades of usage. Apparently PGF doesn't have all its image related code finished for its driver files, otherwise it wouldn't fall-back to \includegraphics for most drivers.

share|improve this answer
    
Although it mentions "...see PDF specification", I have no idea where to start looking for that. Do you know what interpolate does to/for BMPs? –  Werner Oct 28 '11 at 17:36
3  
@Werner: It interpolates the image (raster images only) when zoomed. You then don't see the pixels any longer if you use very high zoom factors. –  Martin Scharrer Oct 28 '11 at 17:37
    
You said that \includegraphics includes a multiple used image only once too. So if I like to include e.g. a (vector) logo in all footers it doesn’t matter wether I use \includegraphics or the PGF mechanism? –  Tobi Oct 28 '11 at 21:47
1  
@Tobi: Yes, using \includegraphics in a header or footer with a vector or raster image will only include the image once, if you use pdftex. With PGF you should use \pgfdeclareimage once in the preamble and use \pgfuseimage in the header or footer. –  Martin Scharrer Oct 29 '11 at 0:07
    
Thank you :-) ... –  Tobi Oct 29 '11 at 10:05

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.