TIFF and LibTiff Mail List Archive


2004.02.20 15:41 "[Tiff] bug in libTiff", by Nick Basargekar
2004.02.20 17:54 "[Tiff] previous message & private tags.", by Nick Basargekar

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

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. 
 * Frank Warmerdam'2000: I modified this to return 1 if TIFF_BEENWRITING 
 * is not set, so that TIFFFlush() will proceed to write out the directory. 
 * The documentation says returning 1 is an error indicator, but not having 
 * been writing isn't exactly a an error.  Hopefully this doesn't cause 
 * problems for other people. 
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 <> 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.