You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary Lucas (Jira)" <ji...@apache.org> on 2020/04/19 13:47:00 UTC

[jira] [Commented] (IMAGING-247) crash on reading tiff image

    [ https://issues.apache.org/jira/browse/IMAGING-247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17087016#comment-17087016 ] 

Gary Lucas commented on IMAGING-247:
------------------------------------

I took a quick look at your sample image in debugger and it looks like the first two bytes in the sequence are -127, -1.   From the TIFF specification for PackBits, -127 means "repeat the next byte 128 times".  Java uses signed bytes, so the -1 is the equivalent of 0b1111111, or 255.

So the 255 is not necessarily a faulty value from the perspective of the PackBits encoding.

But here's the problem...   The BitsPerSample tag (see above) defines the data as having only one bit per sample.  But the existing code in ImageDataReader does not take that into account.  It just passes the 255 down to the PhotometricInterpreterPalette class.

The PhotometricInterpreterPalette runs into a problem because the palette only defines two states.   To make it more robust, it could implement a bounds-check and return a more informative ImageReadException, but that wouldn't do you much good.

Not sure how to handle this, but I'll read through the TIFF spec some more and see what it indicates.

Do you have a JPEG or PNG of what the image ought to look like when decoded?

 

> crash on reading tiff image
> ---------------------------
>
>                 Key: IMAGING-247
>                 URL: https://issues.apache.org/jira/browse/IMAGING-247
>             Project: Commons Imaging
>          Issue Type: Bug
>          Components: Format: TIFF
>    Affects Versions: 1.0-alpha1
>            Reporter: Robin Morier
>            Priority: Major
>         Attachments: neutre.TIFF
>
>
> I get an index out of bounds exception trying to load the attached image.
> {noformat}
> java.lang.ArrayIndexOutOfBoundsException: Index 255 out of bounds for length 2
> 	at org.apache.commons.imaging.formats.tiff.photometricinterpreters.PhotometricInterpreterPalette.interpretPixel(PhotometricInterpreterPalette.java:53)
> 	at org.apache.commons.imaging.formats.tiff.datareaders.DataReaderStrips.interpretStrip(DataReaderStrips.java:179)
> 	at org.apache.commons.imaging.formats.tiff.datareaders.DataReaderStrips.readImageData(DataReaderStrips.java:212)
> 	at org.apache.commons.imaging.formats.tiff.TiffImageParser.getBufferedImage(TiffImageParser.java:659)
> 	at org.apache.commons.imaging.formats.tiff.TiffDirectory.getTiffImage(TiffDirectory.java:163)
> 	at org.apache.commons.imaging.formats.tiff.TiffImageParser.getBufferedImage(TiffImageParser.java:469)
> 	at org.apache.commons.imaging.Imaging.getBufferedImage(Imaging.java:1442)
> 	at org.apache.commons.imaging.Imaging.getBufferedImage(Imaging.java:1404){noformat}
>  
> I'm calling getBufferedImage without any parameters.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)