2010.02.11 21:56 "[Tiff] TIFF and IJG JPEG 8", by Bob Friesenhahn

2010.03.16 22:34 "Re: [Tiff] TIFFVStripSize overflow, JPEG decoding", by Lee Cooper

Thank you Bob, Ed, for pointing out the limits on JPEG size.

In light of this fact I think the file may be more complex than I expected. The example I listed is actually on the small side and I am certain that typical examples cannot be contained within the limits you mention. Looking at tiffdump output for a larger file (listed below) I see unlabeled tags with array values. I'm guessing these are pointers into multiple separate JPEGs. I cannot be sure however because the manufacturer's documentation is still not available.

Supposing I have a pointer to a region of the file that contains an encoded JPEG, and the size of the region in bytes, is there a simple way to decode this region?

-----------------------------------------------------------------------------------------------------------------------

Magic: 0x4949 <little-endian> Version: 0x2a
Directory 0: offset 1750397507 (0x6854f243) next 1907037606 (0x71ab15a6)
ImageWidth (256) LONG (4) 1<159744>
ImageLength (257) LONG (4) 1<109824>
BitsPerSample (258) SHORT (3) 3<8 8 8>

Compression (259) SHORT (3) 1<7>
Photometric (262) SHORT (3) 1<6>
Make (271) ASCII (2) 10<Hamamatsu\0>

Model (272) ASCII (2) 9<C9600-12\0>
StripOffsets (273) LONG (4) 1<1542>
SamplesPerPixel (277) SHORT (3) 1<3>
RowsPerStrip (278) LONG (4) 1<109824>
StripByteCounts (279) LONG (4) 1<1748254397>
XResolution (282) RATIONAL (5) 1<44128>
YResolution (283) RATIONAL (5) 1<43950>
ResolutionUnit (296) SHORT (3) 1<3>

Software (305) ASCII (2) 16<NDP.scan 2.2.60\0>

DateTime (306) ASCII (2) 20<2010:03:05 11:48:44\0>
YCbCrSubsampling (530) SHORT (3) 2<1 1>
ReferenceBlackWhite (532) LONG (4) 6<0 255 128 255 128 255>
65420 (0xff8c) SHORT (3) 1<1>

65421 (0xff8d) FLOAT (11) 1<40>
65422 (0xff8e) SLONG (9) 1<5361304>
65423 (0xff8f) SLONG (9) 1<5804>
65424 (0xff90) SLONG (9) 1<0>

65425 (0xff91) LONG (4) 1<0>
65426 (0xff92) LONG (4) 535392<660 1814 3043 4100 5004 5909 6816 7961 9150 10304 11453 12588 13725 14867 16003 17146 18259 19393 20518 21623 22761 23871 24983 26154 ...>
65428 (0xff94) LONG (4) 1<398050858>
65433 (0xff99) LONG (4) 1<1500>

65439 (0xff9f) SLONG (9) 213<-8570480 12242718 -2 -10208955 12368932 -2 -8570480 12368932 -2 -7058043 12368932 11236400 -6932006 12242718 11239300 -7058043 12242718 11239100 -10334991 12242718 11232400 -10208955 12242718 11233400 ...>

65440 (0xffa0) SLONG (9) 142<0 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 1 8 1 9 1 10 1 11 ...>

65441 (0xffa1) LONG (4) 1<0>
65442 (0xffa2) ASCII (2) 9<C9600-12\0>
65443 (0xffa3) LONG (4) 1<0>
65444 (0xffa4) LONG (4) 1<80>

65445 (0xffa5) SLONG (9) 1<2>
65446 (0xffa6) SLONG (9) 1<0>

>I forget the exact JPEG limit, but I see that these TIFFs are JPEG
>compressed organized as strips and the strip width is close to the
>JPEG limits. Perhaps this is where some overflow is happening (if it
>is happening).
>
>Feel free to test with my free software (GraphicsMagick,
>http://www.GraphicsMagick.org/) with logging enabled
>(-debug coder,exception) since that helps to see many details.
>
>You forgot to tell us what operating system, compiler, and build
>options that you used. Libtiff has certainly been used on files of
>this size but perhaps there is something unusal about your files or
>the build is defective.

Bob
--
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/