Dimension too large. error from pdflatex when using \includegraphics
There's a limit for graphics dimensions, bounded above by \maxdimen
(16384pt
); in the case of the height for images, the limit is around 574cm
to 576cm
for some of the images I tested. For example,
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[height=576cm,width=2cm]{example-image-a}
\end{document}
triggers the error message, but using 575 there's no error (just the obvious warning about overfull \vbox
)
Your image is almost 670cm
high! (clearly higher than \maxdimen
) so the error is triggered. Besides that, what would you do with such a large image compressed to fit into an a4paper document?
Another issue that seems to cause this problem is if the image is in CMYK colorspace (even if the dimensions are below the max limit). To fix this, you can re-save it as an RGB image using Photoshop or another image editing tool, or convert it directly using one of the many converters online such as http://www.cmykconverter.com/
This occurred with XeLateX on the Overleaf platform.
This may happen also if the image has sane size, but has declared incorrect DPI set (for example 800x600 pixels image, but with 2x2 DPI set... which makes it 1000 cm wide).
You can correct the DPI in an image editor (well, if it is not a PDF file), and it should work fine.