# Reusing an image without duplicating it

PGF has a nice feature, declaring an image and re-using it again and again. With a PDF backend, it reduces the size of the output, as the image is embedded in the file only once. However, the PGF manual clearly states that LaTeX users should prefer `\includegraphics` to this mechanism.

Is it possible to mimic this feature, i.e., reusing an image without increasing the file size, using LaTeX's native graphics packages? Would putting the image in a box do this effect?

`\includegraphics` does the trick itself.
• For PDF output I'm sure of that, but not for DVI/PS. There it might depend on the `dvips` tool used. Also AFAIK the `pgf` graphic commands are using `\includegraphics` internally for PDF output. – Martin Scharrer Apr 17 '11 at 7:48
• DVI does not contain images. pdfTeX, dvipdfm(x), XeTeX and LuaTeX reuse the images for pdf output. However, indeed, dvips copys the code repeatedly and produces huge `.ps` file. It seems limited by the background graphics driver. I've no idea for that. – Leo Liu Apr 17 '11 at 9:08
• @Martin The `pgf` graphic commands directly use pdftex commands if the `pdftex` output driver is used. For other drivers (including ps unless I am mistaken), the fallback is to use `\includegraphics`. I believe that there might be a difference between `pgf` and `\includegraphics` when using the `pdftex` engine (I have related remarks of the pgf manual in mind... but perhaps `\includegraphics` has the related features now as well). – Christian Feuersänger Apr 22 '11 at 22:19