AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2006.09.27 10:01 "[Tiff] help", by Robert Scheck
2006.09.26 14:22 "[Tiff] 2003.08.07 16:40 "Custom tags", by Andrey Kiselev", by Robert Scheck
2006.10.11 10:21 "Re: [Tiff] Handling Of SubIFD in Libtiff Ver 3.8.3", by Sebastian Boehmer
2006.10.12 13:01 "Re: [Tiff] Handling Of SubIFD in Libtiff Ver 3.8.3", by Anurag Singh
2006.10.12 13:41 "Re: [Tiff] Handling Of SubIFD in Libtiff Ver 3.8.3", by Sebastian_Böhmer
2006.10.13 05:16 "Re: [Tiff] Handling Of SubIFD in Libtiff Ver 3.8.3", by Anurag Singh
2006.10.14 12:58 "Re: [Tiff] Handling Of SubIFD in Libtiff Ver 3.8.3", by Anurag Singh
2006.10.16 19:35 "Re: [Tiff] Handling Of SubIFD in Libtiff Ver 3.8.3", by Sebastian Boehmer
2006.09.27 12:43 "Re: [Tiff] help", by Joris Van Damme
2006.09.27 13:26 "Re: [Tiff] help", by Gerben Vos
2006.09.27 13:47 "Re: [Tiff] help", by Joris Van Damme

2006.09.26 14:22 "[Tiff] 2003.08.07 16:40 "Custom tags", by Andrey Kiselev", by Robert Scheck

I tried to run this example program,
but after each "TIFFSetField()" I got errormessage like this:
   _TIFFVSetField: test.tif: Invalid tag "MyTag" (not supported by codec).

I'm using LIBTIFF, Version 3.8.2 for Windows.
Do You know, what's the problem?

Test-Code:

#include <tiffio.h>
#include <stdio.h>

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

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) /
sizeof(xtiffFieldInfo[0]) );
}

int main()
{

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

unsigned short iCount;

TIFFSetTagExtender(TagExtender);

tiff = TIFFOpen("test.tif", "r+"); TIFFSetField(tiff, TIFFTAG_ASCIITAG, "Tag contents"); iShort = 263; TIFFSetField(tiff, TIFFTAG_SHORTTAG, 1, &iShort); iLong = 117; TIFFSetField(tiff, TIFFTAG_LONGTAG, 1, &iLong); fFloat = 0.333333; TIFFSetField(tiff, TIFFTAG_RATIONALTAG, 1, &fFloat); fFloat = 0.666666; TIFFSetField(tiff, TIFFTAG_FLOATTAG, 1, &fFloat); dfDouble = 0.1234567; TIFFSetField(tiff, TIFFTAG_DOUBLETAG, 1, &dfDouble); iByte = 89; TIFFSetField(tiff, TIFFTAG_BYTE, 1, &iByte); TIFFRewriteDirectory(tiff); TIFFClose(tiff);

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

        printf("Short tag: %d\n", paiShort[0]);
TIFFGetField(tiff, TIFFTAG_LONGTAG, &iCount, &paiLong);
if (iCount == 1)
        printf("Long tag: %ld\n", paiLong[0]);
TIFFGetField(tiff, TIFFTAG_RATIONALTAG, &iCount, &pafFloat);
if (iCount == 1)
        printf("Rational tag: %f\n", pafFloat[0]);
TIFFGetField(tiff, TIFFTAG_FLOATTAG, &iCount, &pafFloat);
if (iCount == 1)
        printf("Float tag: %f\n", pafFloat[0]);
TIFFGetField(tiff, TIFFTAG_DOUBLETAG, &iCount, &padfDouble);
if (iCount == 1)
        printf("Double tag: %lf\n", padfDouble[0]);
TIFFGetField(tiff, TIFFTAG_BYTE, &iCount, &paiByte);
if (iCount == 1)
        printf("Byte tag: %d\n", paiByte[0]);
TIFFClose(tiff);

    return 0;
}

Robert Scheck
Senior Software Engineer
----------------------------------------
Beta Systems Software AG
Business Line ECM
Hübnerstraße 3, D-86150 Augsburg
Phone +49 (0) 821 - 7941 - 215
Fax +49 (0) 821 - 7941 - 353
Email: robert.scheck@betasystems.com
http://www.betasystems.com

[This message is confidential. It may also be privileged or otherwise protected by work product immunity or other legal rules. If you have received it by mistake please let us know by reply and then delete it from your system; you should not copy