Petr Slaby created PDFBOX-2103:
----------------------------------
Summary: JPXFilter fails to decode some Jpeg2000 images
Key: PDFBOX-2103
URL: https://issues.apache.org/jira/browse/PDFBOX-2103
Project: PDFBox
Issue Type: Bug
Components: Rendering
Affects Versions: 2.0.0
Reporter: Petr Slaby
Attachments: 000001_MTEXT_CS6.pdf, JPXFilter.java.patch
Most of the images in the attached PDF are missing when rendered via PDFBox
(tested in 2.0 head). The reason is a NullPointerException in ImageIO:
java.lang.NullPointerException
at
com.sun.media.imageioimpl.plugins.jpeg2000.J2KMetadata.replace(J2KMetadata.java:962)
at
com.sun.media.imageioimpl.plugins.jpeg2000.J2KMetadata.addNode(J2KMetadata.java:631)
at
jj2000.j2k.fileformat.reader.FileFormatReader.readFileFormat(FileFormatReader.java:279)
at
com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:418)
at
com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.<init>(J2KReadState.java:189)
at
com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.read(J2KImageReader.java:443)
at javax.imageio.ImageReader.read(Unknown Source)
at org.apache.pdfbox.filter.JPXFilter.readJPX(JPXFilter.java:84)
at org.apache.pdfbox.filter.JPXFilter.decode(JPXFilter.java:58)
...
To avoid the problem, the ImageIO has to be instructed to skip reading metadata
of the image, i.e. use reader.setInput(iis, true, true) instead of
reader.setInput(iis) as shown in the attached patch. This is also what
ImageIO.read(stream) does - the method that was used before the commit 1570806.
--
This message was sent by Atlassian JIRA
(v6.2#6252)