2010.09.10 20:37 "[Tiff] Problem with a particular image", by

2010.09.10 20:37 "[Tiff] Problem with a particular image", by

I'm using LibTIFF 3.9.4, and I have an image that is failing.

I'm trying to do a TIFFReadScanline, and the very first call fails with 'LZWDecode: Not enough data at scanline 0 (short 3096 bytes)'. I traced a little further, and found that the very first token it tries to decode returns an EOI (end of image?). The file clearly has a bunch of data after this point. I would happily assume a corrupt image, except I can open the image without problem in Photoshop or MS-Paint. The image renders as completely blank (all white).

Did Adobe & Microsoft take a shortcut here, or am I doing something wrong? I compiled for 32-bit Windows, but I'm running the code in 64-bit Windows. Below are the tags that I hand-decoded from the image.

4D4D - MM (Big Endian)
002A - * (magic # 42)
00002C1A - offset 0x00002c1a
..
000E -> 14 Directory Entries

1

01 00 (ImageWidth)
00 03 (short)
00 00 00 01 (one short)
0c 18 00 00 (3096 pixels per scanline)

2

01 01 (ImageLength)
00 03 (short)
00 00 00 01 (one short)
01 00 00 00 (256 rows)

3

01 02 (BitsPerSample)
00 03 (short)
00 00 00 01 (one short)
00 08 00 00 (8-bits)

4

01 03 Tag = compression
00 03 (short)
00 00 00 01 (one short)
00 05 00 00 (LZW)

5

01 06 Tag = Photometric Interpretation
00 03 (short)
00 00 00 01 (one short)
00 00 00 00 (white is zero)

6

01 11 (strip offsets)
00 04 (long)
00 00 00 01 (one long)
00 00 00 08 (starts at 0x00000008)

7

01 12 (Orientation)
00 03 (short)
00 00 00 01 (one short)
00 01 00 00 (0,0 = top-left)

8

01 15 (SamplesPerPixel)
00 03 (short)
00 00 00 01 (one short)
00 01 00 00

9

01 16 (RowsPerStrip)
00 03 (short)
00 00 00 01 (one short)
01 01 00 00 (257 rows)

10

01 17 (StripByteCounts)
00 04 (long)
00 00 00 01 (one long)
00 00 2c 11 (11281 bytes per strip after compression)

11

01 1a (tag = x-resolution)
00 05 (rational)
00 00 00 01 (one rational)
00 00 2c c8 (4 bytes starting at 0x00002cc8)

(4b 00 00 00) = 19200

12

01 1B (tag = y-resolution)
00 05 (rational)
00 00 00 01 (one rational)
00 00 2c d0 (4 bytes starting at 0x00002cd0)

(4b 00 00 00) = 19200

13

01 1c (PlanarConfiguration)
00 03 (short)
00 00 00 01 (one short)
00 01 00 00 (Chunky = rgbrgbrgb)

14

01 28 (tag = resolutionunit)
00 03 (short)
00 00 00 01 (one short)
00 02 00 00 (inch)

00 00 00 00 (no additional IFD's)

....

Data starts at 0x00000008
80 E2 11 10 38 24 15 0D
07 84 42 61 50 B8 64 36
1D 0F 88 44 62 51 38 A4
data continues from here...