[Tex/LaTex] Dimension too large on a PNG figure under xelatex and beamer


I have PNG image I want to introduce into my presentation. The figure is black and white and the edges are small. When I compile the file in pdflatex everything is fine but when I Compile it with xelatex I get !dimension too large error:

[1] <use  "./figs/surface.png" > [2]
! Dimension too large.
<to be read again> 
l.31 \end{frame}

The line I use:

  \includegraphics<2> [width=0.8\textwidth]{./figs/surface.png}\par

And the file:enter image description here

Here is a MWE:


\begin{frame}{Coarse-Grained (CG) simulation of a membrane}
      \includegraphics<2> [width=0.8\textwidth]{./figs/surface.png}\par
      \includegraphics<3> [width=1.0\textwidth]{./figs/a_lipid_CG.jpg}
        \item bla


Here are links to the used files:
http://www.4shared.com/photo/EK4CPOF2/a_lipid_CG.html http://www.4shared.com/photo/un7JtzXa/surface.html

Best Answer

The a_lipid_CG.jpg seems to cause the issue. As explained below this specific JPG seems to be incompatible with XeTeX.

I get the same error with the following MWE:


Note that the [1] <use "./figs/surface.png" > [2] is not part of the error message, but only a info message printed before it.

After running the JPG image through the conversion tool of Image Magick convert, i.e. convert a_lipid_CG.jpg a_lipid_CG2.jpg and testing the document with this new JPG file, the error disappears. This leads me to the conclusion that your particular JPG file is not fully compatible with XeTeX. Apparently XeTeX has issues reading the size from the meta-data from the JPG, which somehow leads to the "too-large" error.

To fix this please open the JPG file in an image manipulation program and save it again.

Related Question