Dimension too large on a PNG figure under xelatex and beamer

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:

\documentclass{beamer}
\begin{document}
\begin{frame}
\includegraphics{a_lipid_CG.jpg}
\end{frame}
\end{document}.

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.


Similarly to what @Martin-Scharrer said, convert/mogrify worked for me too, but only by explicitly adding a resolution, which seemed to have been missing. So the following fixed the problem (the files had been produced with matplotlib, btw):

mogrify -density 90 myfile.png