Skip to main content

getting IllegalArgumentException: dataType out of range! for some TIFF file

9 replies [Last post]
davidthi808
Offline
Joined: 2005-11-03
Points: 0

Any idea why this is thrown for some TIFF files?

thanks - dave

Error: dataType out of range!
java.lang.IllegalArgumentException: dataType out of range!
at com.sun.media.imageio.plugins.tiff.TIFFTag.getSizeOfType(TIFFTag.java:230)
at com.sun.media.imageioimpl.plugins.tiff.TIFFIFD.initialize(TIFFIFD.java:154)
at com.sun.media.imageioimpl.plugins.tiff.TIFFIFD.initialize(TIFFIFD.java:300)
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageMetadata.initializeFromStream(TIFFImageMetadata.java:81)
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.readMetadata(TIFFImageReader.java:302)
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.seekToImage(TIFFImageReader.java:276)
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.getWidth(TIFFImageReader.java:469)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Harald Kuhr

Hi guys,

On 24. sep. 2010, at 16.03, Thad Humphries wrote:

> tiffdump show two tags with a data type of 7, which is outside the range of 1 thru 5 (see below). I think to read this thing you're going to have to figure out what 7 means (Adobe docs? Adobe tech support?) and modify it in some way that ImageIO will ignore it. That's probably going to be a combination of changing both the data type and the data length.

For some reason I implemented my own TIFF/EXIF parser some time ago, and remember digging into this... Datatypes 6-12 are new types introduced in TIFF 6.0.

Their definitions are something like this [1]:

6 = SBYTE An 8-bit signed (twos-complement) integer.
7 = UNDEFINED An 8-bit byte that may contain anything, depending on
the definition of the field.
8 = SSHORT A 16-bit (2-byte) signed (twos-complement) integer.
9 = SLONG A 32-bit (4-byte) signed (twos-complement) integer.
10 = SRATIONAL Two SLONGs: the first represents the numerator of a
fraction, the second the denominator.
11 = FLOAT Single precision (4-byte) IEEE format.
12 = DOUBLE Double precision (8-byte) IEEE format.

So I guess your field contains some kind of (proprietary) binary data.

[1] http://exif.org/TIFF6.pdf (Adobe) page 16

Best regards,

--
Harald K

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Thad Humphries

Ah! Serves me right for not turning the page (I only read the list on p.
15).

So now I wonder what is being passed for dataType, since 7 is in the range:

public static int getSizeOfType(int dataType) {
if (dataType < MIN_DATATYPE ||dataType > MAX_DATATYPE) {
throw new IllegalArgumentException("dataType out of range!");
}

return sizeOfType[dataType];
}

It would have been nice if they'd also include the value in the exceptions
message!

I'm in the middle of something else, but maybe later I can run this in a
debugger or modify the method and see what the value is.

On Fri, Sep 24, 2010 at 10:31 AM, Harald Kuhr wrote:

> Hi guys,
>
> On 24. sep. 2010, at 16.03, Thad Humphries wrote:
>
> > tiffdump show two tags with a data type of 7, which is outside the range
> of 1 thru 5 (see below). I think to read this thing you're going to have to
> figure out what 7 means (Adobe docs? Adobe tech support?) and modify it in
> some way that ImageIO will ignore it. That's probably going to be a
> combination of changing both the data type and the data length.
>
> For some reason I implemented my own TIFF/EXIF parser some time ago, and
> remember digging into this... Datatypes 6-12 are new types introduced in
> TIFF 6.0.
>
> Their definitions are something like this [1]:
>
> 6 = SBYTE An 8-bit signed (twos-complement) integer.
> 7 = UNDEFINED An 8-bit byte that may contain anything, depending on
> the definition of the field.
> 8 = SSHORT A 16-bit (2-byte) signed (twos-complement) integer.
> 9 = SLONG A 32-bit (4-byte) signed (twos-complement) integer.
> 10 = SRATIONAL Two SLONGs: the first represents the numerator of a
> fraction, the second the denominator.
> 11 = FLOAT Single precision (4-byte) IEEE format.
> 12 = DOUBLE Double precision (8-byte) IEEE format.
>
> So I guess your field contains some kind of (proprietary) binary data.
>
>
>
> [1] http://exif.org/TIFF6.pdf (Adobe) page 16
>
>
> Best regards,
>
> --
> Harald K
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

--
"Hell hath no limits, nor is circumscrib'd In one self-place; but where we
are is hell, And where hell is, there must we ever be" --Christopher
Marlowe, *Doctor Faustus* (v, 121-24)
[att1.html]

davidthi808
Offline
Joined: 2005-11-03
Points: 0

Thank you everyone. I'll ask them to change the data type.

And if anyone does get a chance to figure out why JAI doesn't like this format, please post here as I would like to know.

thanks - dave

Thad Humphries

>From the JavaDoc for TIFFTag.getSizeOfType():
IllegalArgumentException - if datatype is less than MIN_DATATYPE or greater
than MAX_DATATYPE.

Seems an odd error. I'd run tiffinfo and/or tiffdump (from
http://www.libtiff.org/) and see if the types conform to the spec. Maybe
you've got an odd-ball TIFF, like that execrable JPEG Compression in TIFF.

On Thu, Sep 23, 2010 at 1:28 PM, wrote:

> Any idea why this is thrown for some TIFF files?
>
> thanks - dave
>
> Error: dataType out of range!
> java.lang.IllegalArgumentException: dataType out of range!
> at
> com.sun.media.imageio.plugins.tiff.TIFFTag.getSizeOfType(TIFFTag.java:230)
> at
> com.sun.media.imageioimpl.plugins.tiff.TIFFIFD.initialize(TIFFIFD.java:154)
> at
> com.sun.media.imageioimpl.plugins.tiff.TIFFIFD.initialize(TIFFIFD.java:300)
> at
> com.sun.media.imageioimpl.plugins.tiff.TIFFImageMetadata.initializeFromStream(TIFFImageMetadata.java:81)
> at
> com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.readMetadata(TIFFImageReader.java:302)
> at
> com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.seekToImage(TIFFImageReader.java:276)
> at
> com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.getWidth(TIFFImageReader.java:469)
> [Message sent by forum member 'davidthi808']
>
> http://forums.java.net/jive/thread.jspa?messageID=483502
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

--
"Hell hath no limits, nor is circumscrib'd In one self-place; but where we
are is hell, And where hell is, there must we ever be" --Christopher
Marlowe, *Doctor Faustus* (v, 121-24)
[att1.html]

davidthi808
Offline
Joined: 2005-11-03
Points: 0

Hi;

I tried that and nothing jumped out at me - but I'm not a TIFF expert. The header says it is created by Adobe Photoshop CS4 Windows. I put the TIFF up at http://www.windwardreports.com/temp/Chifley_Logo.TIF if you're willing to take a look.

On weird thing, tiffinfo at the end wrote "TIFFReadCustomDirectory: \test\Chifley_Logo.TIF: Can not read TIFF directory." Does that mean part of the file is missing?

thanks - dave

Thad Humphries

Dave,

tiffdump show two tags with a data type of 7, which is outside the range of
1 thru 5 (see below). I think to read this thing you're going to have to
figure out what 7 means (Adobe docs? Adobe tech support?) and modify it in
some way that ImageIO will ignore it. That's probably going to be a
combination of changing both the data type and the data length.

Good luck.

$ tiffdump Chifley_Logo.TIF
Chifley_Logo.TIF:
Magic: 0x4949
Version: 0x2a
Directory 0: offset 493938 (0x78972) next 0 (0)
SubFileType (254) LONG (4) 1<0>
ImageWidth (256) SHORT (3) 1<591>
ImageLength (257) SHORT (3) 1<177>
BitsPerSample (258) SHORT (3) 4<8 8 8 8>
Compression (259) SHORT (3) 1<1>
Photometric (262) SHORT (3) 1<5>
StripOffsets (273) LONG (4) 1<8>
Orientation (274) SHORT (3) 1<1>
SamplesPerPixel (277) SHORT (3) 1<4>
RowsPerStrip (278) SHORT (3) 1<177>
StripByteCounts (279) LONG (4) 1<418428>
XResolution (282) RATIONAL (5) 1<300>
YResolution (283) RATIONAL (5) 1<300>
PlanarConfig (284) SHORT (3) 1<1>
ResolutionUnit (296) SHORT (3) 1<2>
Software (305) ASCII (2) 28
DateTime (306) ASCII (2) 20<2010:07:21 10:18:41\0>
700 (0x2bc) BYTE (1) 69710<0x3c 0x3f 0x78 0x70 0x61 0x63 0x6b 0x65 0x74 0x20
0x62 0x65 0x67 0x69 0x6e 0x3d 0x22 0xef 0xbb 0xbf 0x22 0x20 0x69 0x64 ...>
33723 (0x83bb) UNDEFINED (7) 17<0x1c 0x2 00 00 0x2 00 00 0x1c 0x2 0x5 00 0x5
0x50 0x72 0x69 0x6e 0x74>
34377 (0x8649) BYTE (1) 5702<0x38 0x42 0x49 0x4d 0x4 0x4 00 00 00 00 00 0x11
0x1c 0x2 00 00 0x2 00 00 0x1c 0x2 0x5 00 0x5 ...>
34665 (0x8769) LONG (4) 1<494196>
37680 (0x9330) UNDEFINED (7) 5632<0xd0 0xcf 0x11 0xe0 0xa1 0xb1 0x1a 0xe1 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...>

On Thu, Sep 23, 2010 at 8:10 PM, wrote:

> Hi;
>
> I tried that and nothing jumped out at me - but I'm not a TIFF expert. The
> header says it is created by Adobe Photoshop CS4 Windows. I put the TIFF up
> at http://www.windwardreports.com/temp/Chifley_Logo.TIF if you're willing
> to take a look.
>
> On weird thing, tiffinfo at the end wrote "TIFFReadCustomDirectory:
> \test\Chifley_Logo.TIF: Can not read TIFF directory." Does that mean part of
> the file is missing?
>
> thanks - dave
> [Message sent by forum member 'davidthi808']
>
> http://forums.java.net/jive/thread.jspa?messageID=483565
>

--
"Hell hath no limits, nor is circumscrib'd In one self-place; but where we
are is hell, And where hell is, there must we ever be" --Christopher
Marlowe, *Doctor Faustus* (v, 121-24)
[att1.html]

imagero
Offline
Joined: 2003-11-18
Points: 0

Here is output of Imagero:

NewSubfileType: entry offset: 0x78974 tag: 254 type: LONG count: 1 value: 0
ImageWidth: entry offset: 0x78980 tag: 256 type: SHORT count: 1 value: 591
ImageLength: entry offset: 0x7898c tag: 257 type: SHORT count: 1 value: 177
BitsPerSample: entry offset: 0x78998 tag: 258 type: SHORT count: 4 value: 8 8 8 8 value offset: 66284
Compression: entry offset: 0x789a4 tag: 259 type: SHORT count: 1 value: 1 [uncompressed]
PhotometricInterpretation: entry offset: 0x789b0 tag: 262 type: SHORT count: 1 value: 5 [CMYK]
StripOffsets: entry offset: 0x789bc tag: 273 type: LONG count: 1 value: 8
Orientation: entry offset: 0x789c8 tag: 274 type: SHORT count: 1 value: 1 [(0, 0) is top-left]
SamplesPerPixel: entry offset: 0x789d4 tag: 277 type: SHORT count: 1 value: 4
RowsPerStrip: entry offset: 0x789e0 tag: 278 type: SHORT count: 1 value: 177
StripByteCount: entry offset: 0x789ec tag: 279 type: LONG count: 1 value: 418428
XResolution: entry offset: 0x789f8 tag: 282 type: RATIONAL count: 1 value: 3000000/10000, value offset: 6628c
YResolution: entry offset: 0x78a04 tag: 283 type: RATIONAL count: 1 value: 3000000/10000, value offset: 66294
PlanarConfiguration: entry offset: 0x78a10 tag: 284 type: SHORT count: 1 value: 1 [Chunky format]
ResolutionUnit: entry offset: 0x78a1c tag: 296 type: SHORT count: 1 value: 2 [inch]
Software: entry offset: 0x78a28 tag: 305 type: ASCII count: 28 value: Adobe Photoshop CS4 Windows value offset: 6629c
DateTime: entry offset: 0x78a34 tag: 306 type: ASCII count: 20 value: 2010:07:21 10:18:41 value offset: 662b8
xmp: entry offset: 0x78a40 tag: 700 type: BYTE count: 69710 value: 0x3c 0x3f 0x78 0x70 0x61 0x63 0x6b 0x65 0x74 0x20 ...value offset: 662cc
iptc: entry offset: 0x78a4c tag: 33723 type: UNDEFINED count: 17 value: 0x1c 0x2 0x0 0x0 0x2 0x0 0x0 0x1c 0x2 0x5 0x0 0x5 ...value offset: 7731a
App13: entry offset: 0x78a58 tag: 34377 type: BYTE count: 5702 value: 0x38 0x42 0x49 0x4d 0x4 0x4 0x0 0x0 0x0 0x0 0x0 0x11 ...value offset: 7732c
ExifPointer: entry offset: 0x78a64 tag: 34665 type: LONG count: 1 value: 494196
Unknown: entry offset: 0x78a70 tag: 37680 type: UNDEFINED count: 5632 value: 0xd0 0xcf 0x11 0xe0 0xa1 0xb1 0x1a 0xe1 0x0 0x0 0x0 ...value offset: 78a80

UNDEFINED (7) is valid type.

Harald Kuhr

On 24. sep. 2010, at 16.53, jai-imageio@javadesktop.org wrote:

> Here is output of Imagero:

[...]

> ExifPointer: entry offset: 0x78a64 tag: 34665 type: LONG count: 1 value: 494196
> Unknown: entry offset: 0x78a70 tag: 37680 type: UNDEFINED count: 5632 value: 0xd0 0xcf 0x11 0xe0 0xa1 0xb1 0x1a 0xe1 0x0 0x0 0x0 ...value offset: 78a80

Just out of curiosity (ok, maybe more beaceuse I suspect a bug in my own EXIF parser), is anyone able to parse the EXIF segment in the file [1] (with any tool)?

It seems to me that the EXIF data (at offset 494196 or 0x78A74) overlaps with the 'Unknown' entry at 0x78A70... This could maybe work if the unknown segment is some kind of EXIF wrapper, but I still can't parse it correctly.

I thought all offsets are absolute positions into the stream? Is there something about the EXIF pointer and offsets I don't get? :-)

[1] http://www.windwardreports.com/temp/Chifley_Logo.TIF

Thanks for any hints,

--
Harald K

[att1.html]

Harald Kuhr

On 28. sep. 2010, at 13.31, Harald Kuhr wrote:

> It seems to me that the EXIF data (at offset 494196 or 0x78A74) overlaps with the 'Unknown' entry at 0x78A70...

Ahem.. It does of course not. It starts right after. Apologizes for wasting your bandwidth... ;-)

--
Harald K

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net