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

2020-05-18 Thread Bruno P. Kinoshita (Jira)


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

Bruno P. Kinoshita commented on IMAGING-247:


Pull request merged. Thanks [~gwlucas] !

> 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
>Assignee: Bruno P. Kinoshita
>Priority: Major
> Fix For: 1.0-alpha2
>
> Attachments: IMAGING-247.png, 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)


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

2020-04-20 Thread Robin Morier (Jira)


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

Robin Morier commented on IMAGING-247:
--

Gary,

Thanks for looking into this. The .png you've attached is indeed what it should 
look like.

> 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: IMAGING-247.png, 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)


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

2020-04-19 Thread Gary Lucas (Jira)


[ 
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 0b111, 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)


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

2020-01-17 Thread Robin Morier (Jira)


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

Robin Morier commented on IMAGING-247:
--

Thanks for investigating.
As a temporary workaround I'm converting the TIFFs to white_is_zero scheme (so, 
without the palette).
I've spent some time trying to understand the library code that leads to that 
faulty 255 sample value but couldn't quite get my mind around the meaning of 
the bit shifts etc...

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


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

2020-01-14 Thread Bruno P. Kinoshita (Jira)


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

Bruno P. Kinoshita commented on IMAGING-247:


Thanks for reporting the issue and including the stacktrace and example image. 
Issue reproduced locally. exiftool and getImageInfo both work fine though.
{noformat}
$ exiftool -validate -verbose neutre.TIFF 
  ExifToolVersion = 10.80
  FileName = neutre.TIFF
  Directory = .
  FileSize = 29708
  FileModifyDate = 1578998227
  FileAccessDate = 1578998243
  FileInodeChangeDate = 1578998229
  FilePermissions = 33204
  FileType = TIFF
  FileTypeExtension = TIF
  MIMEType = image/tiff
  ExifByteOrder = II
  + [IFD0 directory with 15 entries]
  | 0)  ImageWidth = 2388
  | 1)  ImageHeight = 1700
  | 2)  BitsPerSample = 1
  | 3)  Compression = 32773
  | 4)  PhotometricInterpretation = 3
  | 5)  StripOffsets = 8 224 440 656 872 1088 1304 1520 1736 1952 2168 2384 
2600 2816 3[snip]
  | 6)  Orientation = 1
  | 7)  SamplesPerPixel = 1
  | 8)  RowsPerStrip = 27
  | 9)  StripByteCounts = 216 216 216 216 216 216 216 216 216 216 216 216 216 
216 1615 [snip]
  | 10) XResolution = 199.9996033 (419429568/2097152)
  | 11) YResolution = 199.9996033 (419429568/2097152)
  | 12) PlanarConfiguration = 1
  | 13) ResolutionUnit = 2
  | 14) ColorMap = ..
  Warning = Invalid count for IFD0 tag 0x0140 ColorMap
  Validate = 0 1 0
Validate {noformat}
{noformat}
Format Details: Tiff v.42
Bits Per Pixel: 1
Comments: 15
0: '256 (0x100: ImageWidth): 2388 (1 Short)'
1: '257 (0x101: ImageLength): 1700 (1 Short)'
2: '258 (0x102: BitsPerSample): 1 (1 Short)'
3: '259 (0x103: Compression): -32763 (1 Short)'
4: '262 (0x106: PhotometricInterpretation): 3 (1 Short)'
5: '273 (0x111: PreviewImageStart): 8, 224, 440, 656, 872, 1088, 1304, 
1520, 1736, 1952, 2168, 2384, 2600, 2816, 3032, 4647, 5950, 6166, 6382, 6598, 
6814, 7030, 7246, 7707, 12209, 12593, 12943, 13292, 13647, 14404, 15357, 15714, 
16702, 18042, 18393, 18963, 21053, 21930, 22254, 22953, 23645, 23879, 24095, 
24311, 24535, 24759, 24979, 25195, 25411, 25840, 26189... (63) (63 Long)'
6: '274 (0x112: Orientation): 1 (1 Short)'
7: '277 (0x115: SamplesPerPixel): 1 (1 Short)'
8: '278 (0x116: RowsPerStrip): 27 (1 Short)'
9: '279 (0x117: PreviewImageLength): 216, 216, 216, 216, 216, 216, 216, 
216, 216, 216, 216, 216, 216, 216, 1615, 1303, 216, 216, 216, 216, 216, 216, 
461, 4502, 384, 350, 349, 355, 757, 953, 357, 988, 1340, 351, 570, 2090, 877, 
324, 699, 692, 234, 216, 216, 224, 224, 220, 216, 216, 429, 349, 216... (63) 
(63 Long)'
10: '282 (0x11a: XResolution): 419429568/2097152 (200) (1 Rational)'
11: '283 (0x11b: YResolution): 419429568/2097152 (200) (1 Rational)'
12: '284 (0x11c: PlanarConfiguration): 1 (1 Short)'
13: '296 (0x128: ResolutionUnit): 2 (1 Short)'
14: '320 (0x140: ColorMap): 0, -1, 0, -1, 0, -1 (6 Short)'
Format: TIFF
Format Name: TIFF Tag-based Image File Format
Compression Algorithm: PackBits
Height: 1700
MimeType: image/tiff
Number Of Images: 1
Physical Height Dpi: 200
Physical Height Inch: 8.500017
Physical Width Dpi: 200
Physical Width Inch: 11.940023
Width: 2388
Is Progressive: false
Is Transparent: false
Color Type: RGB
Uses Palette: true {noformat}
Will need some debugging to check what's going on.

 

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