In Which graphics formats can be included in documents processed by latex or pdflatex?, the answers indicate that that pdfLaTeX understands JPEG2000. For me it doesn't work and the above link seems to be about the only place where a .jp2-positive statement is made.

Could someone please clarify the matter for me?

  • 1
    Are you using it as \includegraphics{file.jp2}? What about renaming it to .jpg? – Werner Feb 2 '14 at 18:55
  • "it doesn't work" is a useless message. Please read chiark.greenend.org.uk/~sgtatham/bugs.html – Martin Schröder Feb 2 '14 at 19:46
  • @Heiko It is a statement of not much use, indeed. Sorry. I tried giving the file in question a .jpg extension. Pdftex then says, "reading JPEG image failed (no JPEG header found)", which could be expected with a file in JPEG2000 format. When I include the file by \includegraphics{file.jb2}, i.e., with the explicit extension, I get "readfilehdr(): reading JBIG2 image file failed: ID string missing". Could this mean there is something wrong with my file? If it means anything, Irfanview recognizes the format and displays the file correctly. – AgoraPD Feb 2 '14 at 20:03
  • That answer was wrong; fixed. – Martin Schröder Feb 2 '14 at 22:45

pdfTeX cannot handle JPEG2000 images, but LuaTeX can.

For LuaTeX pdftex.def can be extended to support .jp2 as file extension for JPEG2000 files:


    \expandafter\ifx\csname Gin@rule@.jp2\endcsname\relax

This adds a rule for .jp2 (and the uppercase variant .JP2) and adds the extension to the search list of the supported graphics extensions.

A small test file worked for AR9.5.5/Linux, but other PDF viewers (xpdf 3.03, ghostscript 9.05, evince 3.4.0) are not able to display the image properly.

  • 1
    You're mixing JBIG2 and JPEG2000 images. – Martin Schröder Feb 2 '14 at 19:49
  • This doesn't help, I am afraid. The error message I now get is, "unknown type of image". Can you confirm that pdfLaTeX is able to handle JPEG2000 files? – AgoraPD Feb 2 '14 at 20:22
  • I am confused. Does luaTeX support JPEG2000 or not? – AlexG Feb 2 '14 at 21:26
  • @AlexG: I had converted a file with image_to_j2k to .jp2 and LuaTeX 0.76.0 could read/include it in the output PDF file. Also the documentation of LuaTeX (4.5.8 img.types) says, that JPEG 2000 is supported. – Heiko Oberdiek Feb 2 '14 at 22:07
  • I installed openjpeg-1.5.1, but luatex fails to embed a jp2 file created with image_to_j2k. Which openjpeg version do you use? The error is (./test.texluatex: ../../../texk/web2c/luatexdir/image/writejp2.w:216: read_jp2_info: Assertion 'hdr.tbox==0x6A502020' failed. – AlexG Feb 17 '14 at 9:29

You may want to convert j2 to jpg by opening it in GIMP (which will take a while and throw a message about converting to sRGB), then export to jpg (or whatever else)

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.