16

MWE

Please use the image linked to below.

\documentclass{article}
\usepackage{graphicx}

\begin{document}
\includegraphics{dank}
\end{document}

Oddly enough, only this picture fails and only when compiling with XeTeX (as opposed to pdfTeX or LuaTeX):

ERROR: Dimension too large.

--- TeX said ---
<to be read again> 
                   b
l.5 \includegraphics{dank}

--- HELP ---
From the .log file...

I can't work with sizes bigger than about 19 feet.
Continue and I'll use the largest value I can.

The dank meme itself is a bit of an eyesore, so I'm not displaying it inline. Please check the shasum to make sure it's still the same file when you download it.

$ shasum dank.jpg
b889bc28b2ccd079073267159db0562f45b58e4d  dank.jpg

What's special about this image? Why does it fail? Its natural setting (as seen with LuaTeX or pdfTeX) is well under 19 feet.

9
  • Related: tex.stackexchange.com/q/51164/24974
    – erik
    Commented Oct 16, 2015 at 1:07
  • Can I ask what context prompted dank memes in LaTeX? This question's title took me completely by surprise. Commented Oct 16, 2015 at 3:00
  • @ArunDebray I'm helping someone clean up and improve a LaTeX guide and, alas, it had this dank meme. Commented Oct 16, 2015 at 3:01
  • @SeanAllred Ah, thanks! Well, if erik's suggestion doesn't work for you, you have a wonderful excuse to substitute a different picture... Commented Oct 16, 2015 at 3:02
  • @ArunDebray I know that changing/re-saving/etc. the picture will allow me to continue – I'm more interested in what's stumped XeTeX in the first place ;) Commented Oct 16, 2015 at 3:23

1 Answer 1

17

The reason is that dank.jpg does not have JFIF, or Exif header. So jpeg driver of XeTeX cannot read density and assumes that it is 1DPI. Thus it becomes very large. The jpeg driver of pdftex also cannot read the density, so assumes it is 72DPI. Solution: Use convert in ImageMagick to add JFIF header.

convert -density 72x72 dank.jpg dank1.jpg

Then converted dank1.jpg will be OK for XeTeX.


To determine if this is the problem with a given image, use (copied from @egreg's comment): identify -verbose dank.jpg | grep Resolution.

2
  • How did you determine that it didn't have the appropriate headers, though? Commented Oct 16, 2015 at 13:13
  • 1
    @SeanAllred With identify -verbose dank.jpg|grep Resolution you get no information, but you get Resolution: 72x72 for dank1.jpg
    – egreg
    Commented Oct 16, 2015 at 15:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .