2008.01.23 17:40 "[Tiff] tiff library and exif", by Jamie L. Finch

2008.02.06 20:03 "[Tiff] Bug in tif_print.c for TIFFTAG_REFERENCEBLACKWHITE", by Edward Lam

Hi,

I've found a bug in tiffinfo when used to display images RGBA images. I

would have checked the bug database at,
     http://bugzilla.remotesensing.org/buglist.cgi?product=libtiff
but it seems to be down at the moment. I've confirmed that the problem
exists in CVS HEAD (since at least 3.7.0).

I have the following image and used tiffinfo on it:

$ ./tiffinfo c:/cygwin/tmp/foo.tiff
TIFF Directory at offset 0x92c3c (601148)
   Image Width: 512 Image Length: 512
   Resolution: 1, 1 (unitless)
   Position: 0, 0
   Bits/Sample: 32
   Sample Format: IEEE floating point
   Compression Scheme: LZW
   Photometric Interpretation: RGB color
   Extra Samples: 1<assoc-alpha>
   Orientation: row 0 top, col 0 lhs
   Samples/Pixel: 4
   Rows/Strip: 2
   Planar Configuration: single image plane

   DateTime: 2008:02:06 13:29:39
   Reference Black/White:
      0:     0     1
      1:     0     1
      2:     0     1
      3: 2.9389e-039 1.10203e-038

Notice that for the Reference Black/White entry, there's garbage printed

out in the last pair. According to page 87 of the TIFF6.pdf, the

ReferenceBlackWhite tag contains 6 rationals (or 3 pairs). tiffinfo

however is display 4 pairs.

I tracked this down to tif_print.c where we have code like this:

case TIFFTAG_REFERENCEBLACKWHITE:
{
        uint16 i;

        fprintf(fd, "  Reference Black/White:\n");
        for (i = 0; i < td->td_samplesperpixel; i++)

            fprintf(fd, "    %2d: %5g %5g\n", i,

                ((float *)raw_data)[2*i+0],
                ((float *)raw_data)[2*i+1]);

        return 1;
}

Notice that i loops from 0 to td_samplesperpixel when I think it should

be looping from 0 to *3* instead. We similarly hardcode this constant

for this tag in other places.

One might think that perhaps the SamplesPerPixel tag should be 3 for

RGBA images but I think the TIFF 6 spec clearly says that

SamplesPerPixel *includes* ExtraSamples in the description for

ExtraSamples (page ) as well as the note on it on page 27.

Thanks,

-Edward