2010.04.26 21:48 "[Tiff] [CRITICAL] libtiff 3.9.3 incorrectly writes out TIFFTAG_REFERENCEBLACKWHITE tags", by Edward Lam

2010.04.26 21:48 "[Tiff] [CRITICAL] libtiff 3.9.3 incorrectly writes out TIFFTAG_REFERENCEBLACKWHITE tags", by Edward Lam

Hi,

I'm currently trying to upgrade from libtiff 3.7.0 to libtiff 3.9.3 and found a serious problem in its handling of TIFFTAG_REFERENCEBLACKWHITE. The problem was unintentionally fixed in libtiff 4.0 due to Adam Goode's patch (http://www.asmail.be/msg0054714754.html).

I haven't analyzed it too much yet but applying Adam's patch to 3.9.3 causes my libtiff usage to work again. When we create an TIFF image, we have code which sets the black/white points as follows:

...
        float points[6];
...
        // set black/white points.
        points[0] = points[2] = points[4] = black;
        points[1] = points[3] = points[5] = white;
        TIFFSetField(myTiff, TIFFTAG_REFERENCEBLACKWHITE, &points);
...
This causes the TIFF file to be generated with:
...
ReferenceBlackWhite (532) LONG (4) 6<0 1132396544 0 1132396544 0 1132396544>
...
The correct tag should be:
...
ReferenceBlackWhite (532) RATIONAL (5) 6<0 255 0 255 0 255>
...

Any ideas?

Thanks,

-Edward