AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2003.08.07 01:12 "[Tiff] Custom tags", by Ashley Dreier
2003.08.07 06:11 "[Tiff] Custom tags", by Andrey Kiselev
2003.08.07 23:59 "[Tiff] Custom tags", by Ashley Dreier
2003.08.07 16:40 "[Tiff] Custom tags", by Andrey Kiselev
2003.08.11 05:09 "[Tiff] Custom tags", by Ashley Dreier
2003.08.11 02:40 "[Tiff] Corection [was: ld.so.1, TIFFmalloc not found]", by Pushkar Pradhan
2003.08.10 04:43 "[Tiff] ld.so.1, TIFFmalloc not found", by Pushkar Pradhan
2003.08.10 05:39 "[Tiff] ld.so.1, TIFFmalloc not found", by Tom Kacvinsky
2003.08.10 05:53 "[Tiff] ld.so.1, TIFFmalloc not found", by Pushkar Pradhan
2003.08.10 13:17 "[Tiff] ld.so.1, TIFFmalloc not found", by Tom Kacvinsky
2003.08.10 16:00 "[Tiff] Corection [was: ld.so.1, TIFFmalloc not found]", by Tom Kacvinsky
2003.08.12 07:48 "[Tiff] Custom tags", by Andrey Kiselev
2003.08.07 06:36 "[Tiff] Custom tags", by Ashley Dreier

2003.08.07 16:40 "[Tiff] Custom tags", by Andrey Kiselev

On Thu, Aug 07, 2003 at 11:12:53AM +1000, Ashley Dreier wrote:

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.

Ashley,

Thank you for report, custom tags support was broken (with except of tags). Problem fixed now, you can take lates revison from CVS ASCII

repository.

There is a test case:

#include <tiffio.h>

#include <stdio.h>

 #define TIFFTAG_ASCIITAG 666
 TIFFTAG_LONGTAG 667 #define
 TIFFTAG_SHORTTAG 668 #define
 TIFFTAG_RATIONALTAG 669 #define
 TIFFTAG_FLOATTAG 670 #define
 TIFFTAG_DOUBLETAG 671 #define
 TIFFTAG_BYTE 672#define

static void TagExtender(TIFF *tiff)

 {

     static const TIFFFieldInfo xtiffFieldInfo[] = {
 TIFFTAG_ASCIITAG,    -1,-1, TIFF_ASCII,     FIELD_CUSTOM,{

           1,  0,      "MyTag" },
 TIFFTAG_SHORTTAG, 1, 1, TIFF_SHORT,  FIELD_CUSTOM, 0, 1,{

             "ShortTag" },
 TIFFTAG_LONGTAG, 1, 1, TIFF_LONG,  FIELD_CUSTOM, 0, 1,{

             "LongTag" },
 TIFFTAG_RATIONALTAG, 1, 1, TIFF_RATIONAL,  FIELD_CUSTOM, 0, 1,{

             "RationalTag" },
 TIFFTAG_FLOATTAG, 1, 1, TIFF_FLOAT,  FIELD_CUSTOM, 0, 1,{

             "FloatTag" },
 TIFFTAG_DOUBLETAG, 1, 1, TIFF_DOUBLE,  FIELD_CUSTOM, 0, 1,{

             "DoubleTag" },
 TIFFTAG_BYTE, 1, 1, TIFF_BYTE,  FIELD_CUSTOM, 0, 1,{

             "DoubleTag" },

     };

     TIFFMergeFieldInfo( tiff, xtiffFieldInfo,
 / sizeof(xtiffFieldInfo[0]) );sizeof(xtiffFieldInfo)

 }

 int main()
 {

     TIFF    *tiff;

     char    *pszString;
    iLong, *paiLong; long
   iShort, *paiShort; short
   fFloat, *pafFloat; float
  dfDouble, *padfDouble; double
    iByte, *paiByte;char

     unsigned short iCount;

     TIFFSetTagExtender(TagExtender);

     tiff = TIFFOpen("test.tif", "r+");
 TIFFTAG_ASCIITAG, "Tag contents");TIFFSetField(tiff,

     iShort = 263;
 TIFFTAG_SHORTTAG, 1, &iShort);TIFFSetField(tiff,

     iLong = 117;
 TIFFTAG_LONGTAG, 1, &iLong);TIFFSetField(tiff,

     fFloat = 0.333333;
 TIFFTAG_RATIONALTAG, 1, &fFloat);TIFFSetField(tiff,

     fFloat = 0.666666;
 TIFFTAG_FLOATTAG, 1, &fFloat); TIFFSetField(tiff,
 = 0.1234567; dfDouble
 TIFFTAG_DOUBLETAG, 1, &dfDouble);TIFFSetField(tiff,

     iByte = 89;
 TIFFTAG_BYTE, 1, &iByte); TIFFSetField(tiff,
TIFFRewriteDirectory(tiff);

     TIFFClose(tiff);

     tiff = TIFFOpen("test.tif", "r");
 TIFFTAG_ASCIITAG, &pszString); TIFFGetField(tiff,
 tag: %s\n", pszString); printf("ASCII
 TIFFTAG_SHORTTAG, &iCount, &paiShort);TIFFGetField(tiff,

     if (iCount == 1)
 tag: %d\n", paiShort[0]); printf("Short
 TIFFTAG_LONGTAG, &iCount, &paiLong);TIFFGetField(tiff,

     if (iCount == 1)
 tag: %ld\n", paiLong[0]); printf("Long
 TIFFTAG_RATIONALTAG, &iCount, &pafFloat);TIFFGetField(tiff,

     if (iCount == 1)
 tag: %f\n", pafFloat[0]); printf("Rational
 TIFFTAG_FLOATTAG, &iCount, &pafFloat);TIFFGetField(tiff,

     if (iCount == 1)
 tag: %f\n", pafFloat[0]); printf("Float
 TIFFTAG_DOUBLETAG, &iCount, &padfDouble);TIFFGetField(tiff,

     if (iCount == 1)
 tag: %lf\n", padfDouble[0]); printf("Double
 TIFFTAG_BYTE, &iCount, &paiByte);TIFFGetField(tiff,

     if (iCount == 1)
 tag: %d\n", paiByte[0]);printf("Byte

     TIFFClose(tiff);

     return 0;
 }

Regards,
Andrey

 --
 Andrey V. Kiselev

Home phone: +7 812 5274898 ICQ# 26871517