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.

In his answer to the question Tikz: using external images as building blocks. Stefan Kottwitz says:

The pgf way may be preferred if the document size matters and graphics are multiply used or if masking is desired.

When is there a problem regarding large document size caused be multiple inclusions of the same image? With a random photo in jpg-format I get the results below using the following test-files:

\documentclass{article}
\usepackage{graphicx}
\pagestyle{empty}
\begin{document}

\newcount\n
\n=0
\loop\ifnum\n<100 \advance\n by1
\includegraphics[width=5cm]{IMG_1823.JPG}
\newpage
\repeat

\end{document}

and

\documentclass{article}
\usepackage{pgf}
\pgfdeclareimage[width=5cm]{test}{IMG_1823.JPG}
\pagestyle{empty}
\begin{document}

\newcount\n
\n=0
\loop\ifnum\n<100 \advance\n by1
\pgfuseimage{test}
\newpage
\repeat

\end{document}

Compiling with pdfTeX-1.40.10 the resulting document sizes are (output from pdfinfo):

pgf-version: 
File size:      1673589 bytes

Graphicx-version:
File size:      1667806 bytes

The photo is about 1.6 Mb:

$ du IMG_1823.JPG 
1592    IMG_1823.JPG

Adding \pdfcompresslevel=0 and inspecting the contents of the pdf-file directly both methods seem (as far as I can tell) to embed the image data once only?

share|improve this question
add comment

1 Answer 1

up vote 8 down vote accepted

The FAQ says that repeated graphics are only a problem if you are producing PostScript as the final format. Distillation of the PostScript to PDF (by ghostscript or Distiller) will consolidate the figures, as will direct production of PDF via pdftex.

In the case that small PostScript files are the desired outcome, the FAQ offers several techniques (of varying sneakiness) to ensure that multiply-included graphics are only inserted once.

share|improve this answer
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.