AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2003.11.17 00:45 "[Tiff] TIFF, v3.6.0. Fetching "custom" tags", by Chris Losinger
2003.11.17 14:23 "[Tiff] TIFF, v3.6.0. Fetching "custom" tags", by Frank Warmerdam
2003.11.17 15:16 "[Tiff] TIFF, v3.6.0. Fetching "custom" tags", by Andrey Kiselev
2003.11.17 16:07 "[Tiff] TIFF, v3.6.0. Fetching "custom" tags", by Frank Warmerdam
2003.11.17 16:26 "[Tiff] TIFF, v3.6.0. Fetching "custom" tags", by Andrey Kiselev
2003.11.18 02:13 "[Tiff] TIFF, v3.6.0. Fetching "custom" tags", by Ross Finlayson
2003.11.18 06:59 "[Tiff] TIFF, v3.6.0. Fetching "custom" tags", by Ross Finlayson
2003.12.26 11:51 "Re: [Tiff] writing custom tags with TIFFSetField", by Andrey Kiselev
2003.12.26 19:17 "Re: [Tiff] CopyTag error again...", by Andrey Kiselev
2003.12.26 18:48 "[Tiff] CopyTag error again...", by Carl J. Collin
2003.11.18 15:05 "[Tiff] TIFF, v3.6.0. Fetching "custom" tags", by Finlayson, Ross
2003.11.18 23:08 "[Tiff] TIFF Q about pseudo-tags for Pixar", by Chris Losinger
2003.11.19 02:20 "[Tiff] TIFF Q about pseudo-tags for Pixar", by Frank Warmerdam

2003.12.26 19:17 "Re: [Tiff] CopyTag error again...", by Andrey Kiselev

On Fri, Dec 26, 2003 at 12:48:39PM -0600, Carl J. Collin wrote:
> Hey Andrey, thank for taking a look at this... but now... Now I get
> the simple error that it could not write that tag... I have attached
> the file in question as a zip file, just unzip. Can you check it out?
> This is the error.
> Carl2.tif: Error writing data for field "Wang".

Sorry again... Another small mistake :-) There are a patch (to clear out
what changed) and corrected file itself.

--- copytag.c.bak       Fri Dec 26 22:12:56 2003
+++ copytag.c   Fri Dec 26 22:14:09 2003

@@ -17,7 +17,8 @@

{

    TIFF    *in, *out;
    char    *buf, *wang;

-    int     i, count;
+    int     i;
+    short   count;

    if (argc < 3)
    {

@@ -36,6 +37,7 @@

    }

    TIFFGetField(in, TIFFTAG_WANG, &count, &wang);

+    fprintf(stdout, "Wang tag length: %d\n", count);

    out = TIFFOpen(argv[2], "w");
    if (!out)

--
Andrey V. Kiselev

Home phone: +7 812 5274898 ICQ# 26871517

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

#define TIFFTAG_WANG 32932

static void TagExtender(TIFF *tiff)
{
    static const TIFFFieldInfo xtiffFieldInfo[] = {

        { TIFFTAG_WANG, -1, -1, TIFF_BYTE,  FIELD_CUSTOM,   0,  1,  "Wang" }

};

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

int main(int argc, char **argv)
{

    TIFF    *in, *out;
    char    *buf, *wang;

    int     i;
    short   count;

    if (argc < 3)
    {
        fprintf(stderr, "Usage: %s in.tiff out.tiff\n", argv[0]);
        return 0;
    }

/* Register the custom tag hadler */ TIFFSetTagExtender(TagExtender);

    in = TIFFOpen(argv[1], "r");
    if (!in)
    {
        fprintf(stderr, "Can't open input file %s\n", argv[1]);
        return 1;
    }

    TIFFGetField(in, TIFFTAG_WANG, &count, &wang);

fprintf(stdout, "Wang tag length: %d\n", count);

    out = TIFFOpen(argv[2], "w");
    if (!out)
    {
        fprintf(stderr, "Can't open output file %s\n", argv[2]);
        TIFFClose(in);
        return 2;
    }

TIFFSetField(out, TIFFTAG_IMAGEWIDTH, 256);

TIFFSetField(out, TIFFTAG_IMAGELENGTH, 256);

TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8);

TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 3);

TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);

TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);

    TIFFSetField(out, TIFFTAG_WANG, count, wang);

buf = _TIFFmalloc(3 * 256 * 256);

    TIFFWriteEncodedStrip(out, 0, buf, 3 * 256 * 256);

    _TIFFfree(buf);