AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

2004.02.20 15:41 "[Tiff] bug in libTiff", by Basargekar, Nick

There appears to be a bug in libTIFF 3.6.1(for win32) which prevents the writing out of changed TIFF fields.

*

 * Flush buffered data to the file.

 *

 */

int

TIFFFlushData(TIFF* tif)

{

        if ((tif->tif_flags & TIFF_BEENWRITING) == 0)

               return (0);

        if (tif->tif_flags & TIFF_POSTENCODE) {

               tif->tif_flags &= ~TIFF_POSTENCODE;

               if (!(*tif->tif_postencode)(tif))

                       return (0);

        }

        return (TIFFFlushData1(tif));

}

Frank's comment's don't make any sense because returning 0 is an error indicator according to the docs.

So I changed it to

        if ((tif->tif_flags & TIFF_BEENWRITING) == 0)

                return (TIFFFlushData1(tif));

and then reading/writing of fields started working.

Basically, I'm trying to write out a byte array to a private field for use within this organization.

The contrib\tags example in libTiff doesn't appear to be compatible with 3.6.1, so I followed the instructions at http://www.libtiff.org/internals.html#AddingTags <http://www.libtiff.org/internals.html#AddingTags> and along with the change mentioned above, reading/writing of the private field works ok with libTiff.

However Windows Preview can't view the file after the tag is added. Photoshop 7.0 gives a nasty warning dialog about the file possibly being corrupt, but the file seems to open fine.

I found that even changing a "normal" field like "TIFFTAG_ARTIST" caused the same problems. I'm just wondering if anyone has encountered a similar issue or has any info on the subject. Any feedback at all is greatly appreciated.

Nick Basargekar
Software Engineer, Core Technology Group
PEI/Atari, Inc.
http://www.atari.com <http://www.atari.com>