Return-Path: <tiff-bounces@lists.maptools.org>
Received: from inas022.isp.belgacom.be (localhost [127.0.0.1])
        by inav020.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-AV-3.00) with ESMTP id k17CCLGn024566
        for <joris.at.lebbeke@skynet.be>; Tue, 7 Feb 2006 13:12:21 +0100
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx002.isp.belgacom.be (inmx002.isp.belgacom.be [195.238.5.7])
        by inas022.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-AS-2.03) with ESMTP id k17CCCh2014364
        for <joris.at.lebbeke@skynet.be>; Tue, 7 Feb 2006 13:12:13 +0100
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153] (may be forged))
        by inmx002.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id k17CC3Fo007524
        for <joris.at.lebbeke@skynet.be>; Tue, 7 Feb 2006 13:12:03 +0100
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (duke.maptools.org [127.0.0.1])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id k17C5EeB027659;
	Tue, 7 Feb 2006 07:05:31 -0500
Received: from outmx014.isp.belgacom.be (outmx014.isp.belgacom.be
	[195.238.4.69])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id k17C49JW027552
	for <tiff@lists.maptools.org>; Tue, 7 Feb 2006 07:04:10 -0500
Received: from outmx014.isp.belgacom.be (localhost [127.0.0.1])
	by outmx014.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with
	ESMTP id k17C46Io004475
	for <tiff@lists.maptools.org>; Tue, 7 Feb 2006 13:04:07 +0100
	(envelope-from <joris.at.lebbeke@skynet.be>)
Received: from dfgrrxsknr4e (39-184.246.81.adsl.skynet.be [81.246.184.39])
	by outmx014.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with SMTP
	id k17C3vB4004361; Tue, 7 Feb 2006 13:03:57 +0100
	(envelope-from <joris.at.lebbeke@skynet.be>)
Message-ID: <005001c62bde$9cb43e30$27b8f651@dfgrrxsknr4e>
From: "Joris" <joris.at.lebbeke@skynet.be>
To: <dermot@sciencephoto.com>, <tiff@lists.maptools.org>
References: <43E875BF.29110.6562A494@dermot.sciencephoto.co.uk>
Subject: Re: [Tiff] Re: Mega newbie question
Date: Tue, 7 Feb 2006 12:48:00 +0100
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2800.1506
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
Cc: 
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.4
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=subscribe>
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-UIDL: 000000000023ceae.00001268
X-MSP-STORE: Tue, 07 Feb 2006 13:12:30 +0100
Status:   

Dermot Paikkos wrote:
> > TIFFGetField(tiff, 33424, &count, &data);
> > printf("Tag %d: %d, count %d0, 33424, *(uint32 *)data, count);
> > TIFFGetField(tiff, 36867, &count, &data);
> > printf("Tag %d: %s, count %d0, 36867, (char *)data, count);
>
> Is there a missing " mark here?

Yes, indeed.

>   int hasPSfield;
>   unsigned long imageOffset, result;
>   uint16 count;
>   void *data;
>
>   TIFF* tif = TIFFOpen("test.tif", "r");
>   if (tif == NULL) {
>         printf("Failed to open file\n");
>         exit(8);
>   }
>    TIFFGetField(tif,TIFFTAG_PHOTOSHOP &hasPSfield);
>
>    if (hasPSfield < 1) {
>       printf("No PhotoShop tag found\n");
>         exit(8);
>   }
>   TIFFGetField(tif, hasPSfield, &count, &data);
>   printf("Tag %d: %d, count %d\n", hasPSfield, *(uint32 *)data,
> count);

No, don't use TIFFGetField twice. Do it like this:

TIFF* tif = TIFFOpen("test.tif", "r");
if (tif == NULL) ...
if (TIFFGetField(tif,TIFFTAG_PHOTOSHOP,&count,&data)==0)
{
  printf("No PhotoShop tag found\n");
  exit(8);
}

/* value of Photoshop tag is count bytes long, and its value is loaded
into the memory pointed to by data */

> TIFFReadDirectory: Warning, test.tif: wrong data type 1 for
> "XMLPacket"; tag ignored.
> TIFFReadDirectory: Warning, test.tif: unknown field with tag 34665
> (0x8769) encountered.

Ignore above warnings.

BTW, I just noticed, the situation with the uint16 count is corrected
for the Photoshop tag. Declare count as uint32 instead.

I still think the general case should be uint32, instead of uint16,
though, but this should not bother you.


Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html

_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
