2003.08.07 01:12 "[Tiff] Custom tags", by Ashley Dreier

2003.08.07 01:12 "[Tiff] Custom tags", by Ashley Dreier

Hi all.

I've been trying to port some of our old software to use the new CUSTOM tag facility (v3.6.0 beta 2 TIFF source). I am able to read out the custom tags stored in my TIFF images using TIFFGetField() after making a call to TIFFSetTagExtender() to 'configure' my custom tags. The problem I'm having at the moment is that I don't seem able to store modifed versions of the custom tag data to the file. I open the files using the 'r+' mode (i.e. read/write) and grab the directory/tag information. The TIFFGetField() function confirms that I'm reading the custom data correctly. I then use TIFFSetField() to modify the custom tag data and again call TIFFGetField() to confirm that the data has changed (at least in the TIFF data structure). The next thing I do is a TIFFClose(). This appears to close the file handle, but the file has not been updated with the new tag data. I tried doing a 'TIFFRewriteDirectory()' before calling TIFFClose() to try to force the directory update, but this generates a 'segfault', so I assume that I'm not using the CUSTOM tags correctly. I've also tried 'TIFFCheckpointDirectory()' with a similar problem. In both cases, the resultant TIFF file is corrupted and no longer readable by the TIFF library.

In my case, I am altering a TIFF_ASCII tag, but the segfault seems to occur in a different custom tag (TIFF_SHORT format). On checking further, I seem to also get the same behaviour even when I don't modify any of the custom tags originally present in the file (but still call TIFFRewriteDirectory).

The new tags I am adding are standard types (ASCII, short, long) so I wouldn't have thought there would be too much problem using them. Any help/suggestions would be much appreciated. I'm happy to provide some source if it is appropriate.



Ashley J. Dreier.                     Email: Ashley.Dreier@csiro.au
CSIRO Manufacturing and Infrastructure Tech, Phone: +61 3 9662 7799
Locked Bag No. 9,                            Fax:   +61 3 9662 7851
Preston, Vic, 3072, Australia.
URL: http://www.msa.cmst.csiro.au/cmst/automation/staff/ajd