Return-Path: <tiff-admin@remotesensing.org>
Received: from gee.skynet.be (gee.skynet.be [195.238.2.99])
        by twentyeight.skynet.be (8.12.9/8.12.9/Skynet-MAILSTORE-2.14) with ESMTP id hBQCUG3o013594
        for <joris.at.lebbeke@skynet.be>; Fri, 26 Dec 2003 13:30:16 +0100
        (envelope-from <tiff-admin@remotesensing.org>)
Received: from yoda.imagelinks.com ([208.24.120.42])
        by gee.skynet.be (8.12.9/8.12.9/Skynet-IN-2.32) with ESMTP id hBQCTe02028048
        for <joris.at.lebbeke@skynet.be>; Fri, 26 Dec 2003 13:29:41 +0100
        (envelope-from <tiff-admin@remotesensing.org>)
Received: from yoda.imagelinks.com (localhost.localdomain [127.0.0.1])
	by yoda.imagelinks.com (8.11.6/8.11.2) with ESMTP id hBQCT5l06499;
	Fri, 26 Dec 2003 07:29:05 -0500
Received: from ahk.pu.ru (ahk.pu.ru [193.124.85.198])
	by yoda.imagelinks.com (8.11.6/8.11.2) with ESMTP id hBQCSHl06477
	for <tiff@remotesensing.org>; Fri, 26 Dec 2003 07:28:17 -0500
Received: from wg.pu.ru (wg.pu.ru [193.124.85.219])
	by ahk.pu.ru (8.12.9p2/8.12.9) with ESMTP id hBQCSGE7047361
	for <tiff@remotesensing.org>; Fri, 26 Dec 2003 15:28:16 +0300 (MSK)
	(envelope-from dron@ak4719.spb.edu)
Received: (from uucp@localhost)
	by wg.pu.ru (8.9.1a/8.9.1) with UUCP id MAA26091
	for tiff@remotesensing.org; Fri, 26 Dec 2003 12:28:16 GMT
Received: from ak4719.spb.edu (localhost [127.0.0.1])
	by ak4719.spb.edu (8.12.1/8.12.1/Debian -5) with ESMTP id hBQBpkmY004972
	for <tiff@remotesensing.org>; Fri, 26 Dec 2003 14:51:46 +0300
Received: (from dron@localhost)
	by ak4719.spb.edu (8.12.1/8.12.1/Debian -5) id hBQBpk4Z004969
	for tiff@remotesensing.org; Fri, 26 Dec 2003 14:51:46 +0300
From: Andrey Kiselev <dron@ak4719.spb.edu>
To: tiff@remotesensing.org
Subject: Re: [Tiff] writing custom tags with TIFFSetField
Message-ID: <20031226115146.GB3463@ak4719.spb.edu>
Mail-Followup-To: tiff@remotesensing.org
References: <BAY8-DAV12oTJ5w0cdr00012c61@hotmail.com>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="FkmkrVfFsRoUs1wW"
Content-Disposition: inline
In-Reply-To: <BAY8-DAV12oTJ5w0cdr00012c61@hotmail.com>
X-GnuPG-Key: http://www.srces.spb.org/dron/export.home.key
X-Face: "t+se9s~+y~[XUH]L|pmeO3Pt/Q@DNv**S,d@_1-C=}/,c%<3Qp]eu!ok<"2lYJm$!9qVcg
 F?7o*L;|$`6|Q|>Rt-cU%2_y@6tQ|`!Li}TsvZvEKx;>fuY=fc(=sX^`7Wmw8%SsR`AvM$a;0U/eN\
 P?B\FTyqD,0np$U2!*'z_4D,VPlFf?bN0&zYf"zF0s!7Tl7?$we)xD0@lL>[h|8bhys0i.g|zLnu@C
 Ti@d]i=[!:j1CB\5/TF[m]`lfHfaqSN[0qn@T3zeosV/[LAss{@p_?],x*j8P_9t[}uHD^X-;j~\M!
 gyTly;fj`}&Y~i{<#bN.#QmkE}#T`dxP.I1\.)_MEN{@#W
User-Agent: Mutt/1.5.3i
Sender: tiff-admin@remotesensing.org
Errors-To: tiff-admin@remotesensing.org
X-BeenThere: tiff@remotesensing.org
X-Mailman-Version: 2.0.11
Precedence: bulk
List-Help: <mailto:tiff-request@remotesensing.org?subject=help>
List-Post: <mailto:tiff@remotesensing.org>
List-Subscribe: <http://remotesensing.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=subscribe>
List-Id: TIFF and libtiff discussion <tiff.remotesensing.org>
List-Unsubscribe: <http://remotesensing.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=unsubscribe>
List-Archive: <http://remotesensing.org/pipermail/tiff/>
Date: Fri, 26 Dec 2003 14:51:46 +0300
X-UIDL: 9cc409a572c0d703c956e18e47478f70


--FkmkrVfFsRoUs1wW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Wed, Dec 24, 2003 at 12:04:19PM -0600, Carl J. Collin wrote:
> I am trying to update tiffcp to read and write a custom tag (Wang
> Annotations).  Well, in the newest CVS it looks like TIFFGetField
> might be finally able to acquire the custom tag data.  But when I try
> and write it using TIFFSetField it seems to be getting written to a
> different tag number than what was specified on the tag line.  Beyond
> that, I can't figure out how writing to the TIFFTagValue that is
> specified in the default section of _TIFFVSetField actually writes to
> the new tiff directory.  Has anyone seen any examples of reading and
> writing to custom tags using the new interface in 3.6.X?

Carl,

It is a bit tricky to modify tiffcp to enable custom tags copying. I'm
recommend ti fill the feature request and shall try to implement such a
feature in the next libtiff release.

I have attached an example code which shows how you can copy your tag.

                                      Regards,
				      Andrey  

-- 
Andrey V. Kiselev
Home phone:  +7 812 5274898  ICQ# 26871517

--FkmkrVfFsRoUs1wW
Content-Type: text/x-csrc; charset=us-ascii
Content-Disposition: attachment; filename="copytag.c"

#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,   1,  0,  "Wang" }
    };

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

int main(int argc, char **argv)
{
    TIFF    *in, *out;
    char    *buf, *wang;
    int     i, 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);

    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);

    TIFFClose(out);
    TIFFClose(in);

    return 0;
}


--FkmkrVfFsRoUs1wW--
_______________________________________________
Tiff mailing list
Tiff@remotesensing.org
http://remotesensing.org/mailman/listinfo/tiff
