Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
Are you using it as \includegraphics{file.jp2}? What about renaming it to .jpg? –  Werner Feb 2 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 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 at 20:03
    
That answer was wrong; fixed. –  Martin Schröder Feb 2 at 22:45

1 Answer 1

up vote 11 down vote accepted

pdfTeX cannot handle JPEG2000 images, but LuaTeX can.

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

Workaround:

\usepackage{graphicx}
\usepackage{ifluatex}
\ifluatex
  \usepackage{ifpdf}
  \ifpdf
    \expandafter\ifx\csname Gin@rule@.jp2\endcsname\relax
      \DeclareGraphicsRule{.jp2}{jpg}{.jp2}{#1}
      \DeclareGraphicsRule{.JP2}{jpg}{.JP2}{#1}
      \usepackage{grfext}
      \AppendGraphicsExtensions{.jp2,.JP2}
    \fi
  \fi  
\fi

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.

share|improve this answer
1  
You're mixing JBIG2 and JPEG2000 images. –  Martin Schröder Feb 2 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 at 20:22
    
@MartinSchröder: Thanks, fixed. –  Heiko Oberdiek Feb 2 at 20:25
    
I am confused. Does luaTeX support JPEG2000 or not? –  AlexG Feb 2 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 at 22:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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