Please use the image linked to below.



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> 
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.

  • Related: tex.stackexchange.com/q/51164/24974 – erik Oct 16 '15 at 1:07
  • Can I ask what context prompted dank memes in LaTeX? This question's title took me completely by surprise. – Arun Debray Oct 16 '15 at 3:00
  • @ArunDebray I'm helping someone clean up and improve a LaTeX guide and, alas, it had this dank meme. – Sean Allred Oct 16 '15 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... – Arun Debray Oct 16 '15 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 ;) – Sean Allred Oct 16 '15 at 3:23

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.

|improve this answer|||||
  • How did you determine that it didn't have the appropriate headers, though? – Sean Allred Oct 16 '15 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 Oct 16 '15 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.