Return-Path: <tiff-bounces@remotesensing.org>
Received: from xserve.flids.com (adsl-065-083-169-202.sip.mco.bellsouth.net [65.83.169.202])
        by inmx005.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id j2TN9N1V032508
        for <joris.at.lebbeke@skynet.be>; Wed, 30 Mar 2005 01:09:27 +0200
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from adsl-065-083-169-202.sip.mco.bellsouth.net (localhost [127.0.0.1])
	by xserve.flids.com (Postfix) with ESMTP
	id EA0C2193B754; Tue, 29 Mar 2005 18:09:01 -0500 (EST)
X-Original-To: tiff@remotesensing.org
Delivered-To: tiff@remotesensing.org
Received: from hank.shelbyville.oz (ppp47-112.lns1.adl1.internode.on.net
	[150.101.47.112])
	by xserve.flids.com (Postfix) with ESMTP id 6D13B193B730
	for <tiff@remotesensing.org>; Tue, 29 Mar 2005 18:08:58 -0500 (EST)
Received: from ron by hank.shelbyville.oz with local (Exim 4.50)
	id 1DGPpB-0002WH-GY
	for tiff@remotesensing.org; Wed, 30 Mar 2005 08:38:41 +0930
Date: Wed, 30 Mar 2005 08:38:41 +0930
To: tiff@remotesensing.org
Message-ID: <20050329230841.GA4298@hank.shelbyville.oz>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.8i
From: Ron <ron@debian.org>
Subject: [Tiff] [patch] little things
X-BeenThere: tiff@remotesensing.org
X-Mailman-Version: 2.1.2
Precedence: list
List-Id: TIFF and libtiff discussion  <tiff.remotesensing.org>
List-Unsubscribe: <http://xserve.flids.com/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=unsubscribe>
List-Archive: <http://xserve.flids.com/pipermail/tiff>
List-Post: <mailto:tiff@remotesensing.org>
List-Help: <mailto:tiff-request@remotesensing.org?subject=help>
List-Subscribe: <http://xserve.flids.com/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=subscribe>
Sender: tiff-bounces@remotesensing.org
Errors-To: tiff-bounces@remotesensing.org
X-UIDL: 000000000023ceae.0000001f
X-MSP-STORE: Wed, 30 Mar 2005 01:09:35 --21-99
Status:   


Hi,

I've got a couple of little things first off, all re current cvs HEAD.
Unless I'm mistaken, we can't just add the exif tags in a neat block
to tif_dirinfo.c, we rely on that array being ordered by tag and bsearch
it later.  The first hunk below fixes that for the exif tags that were
added, I've not checked the DNG ones that were also added.  The second
hunk changes find by name to use lsearch, since the array is ordered by
key not name.

I'm also using the following in the TIFFClientOpen replacement I posted
previously, (so it won't apply cleanly to HEAD except by hand).  The
problem it fixes is pathological but potentially real I think.  If you
try to write a tiff to a filename that already exists, we try to read
the header from the file instead of just writing the one we have.  If
the byte sex of the header on file is different to the tiff you think
you are about to write, it would seem things might go pear shaped.  That
may not be the only way, so its simpler and safer to just not try to
read it if we are writing I think, as a minimal patch something like so:

 	/*
 	 * Read in TIFF header.
 	 */
-	if (!ReadOK(tif, &tif->tif_header, sizeof (TIFFHeader))) {
+	if ( mode[ 0 ] == 'w' ||
+	     !ReadOK(tif, &tif->tif_header, sizeof (TIFFHeader))) {
 		if (tif->tif_mode == O_RDONLY) {
 			TIFFError(name, "Cannot read TIFF header");
 			goto bad;

Pass by value for the custom tags was a very welcome addition too,
thanks Andrey!

  Ron


Index: libtiff/tif_dirinfo.c
===================================================================
RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dirinfo.c,v
retrieving revision 1.40
diff -u -r1.40 tif_dirinfo.c
--- libtiff/tif_dirinfo.c	18 Mar 2005 14:27:30 -0000	1.40
+++ libtiff/tif_dirinfo.c	29 Mar 2005 22:33:31 -0000
@@ -247,20 +247,18 @@
 /* end Pixar tags */
     { TIFFTAG_RICHTIFFIPTC, -1, -3, TIFF_LONG,   FIELD_RICHTIFFIPTC, 
       FALSE,    TRUE,   "RichTIFFIPTC" },
-/* begin EXIF tags */
-    { TIFFTAG_EXIFIFD,		1, 1,	TIFF_LONG,	FIELD_CUSTOM,
-      FALSE,	FALSE,	"EXIFIFDOffset" },
-    { TIFFTAG_GPSIFD,		1, 1,	TIFF_LONG,	FIELD_CUSTOM,
-      FALSE,	FALSE,	"GPSIFDOffset" },
-    { TIFFTAG_INTEROPERABILITYIFD,	1, 1,	TIFF_LONG,	FIELD_CUSTOM,
-      FALSE,	FALSE,	"InteroperabilityIFDOffset" },
-/* end EXIF tags */
     { TIFFTAG_PHOTOSHOP,    -1, -3, TIFF_BYTE,   FIELD_PHOTOSHOP, 
       FALSE,    TRUE,   "Photoshop" },
+    { TIFFTAG_EXIFIFD,		1, 1,	TIFF_LONG,	FIELD_CUSTOM,
+      FALSE,	FALSE,	"EXIFIFDOffset" },
     { TIFFTAG_ICCPROFILE,	-1, -3, TIFF_UNDEFINED,	FIELD_ICCPROFILE,
       FALSE,	TRUE,	"ICC Profile" },
+    { TIFFTAG_GPSIFD,		1, 1,	TIFF_LONG,	FIELD_CUSTOM,
+      FALSE,	FALSE,	"GPSIFDOffset" },
     { TIFFTAG_STONITS,		 1, 1, TIFF_DOUBLE,	FIELD_STONITS,
       FALSE,	FALSE,	"StoNits" },
+    { TIFFTAG_INTEROPERABILITYIFD,	1, 1,	TIFF_LONG,	FIELD_CUSTOM,
+      FALSE,	FALSE,	"InteroperabilityIFDOffset" },
 /* begin DNG tags */
     { TIFFTAG_DNGVERSION,	4, 4,	TIFF_BYTE,	FIELD_CUSTOM, 
       FALSE,	FALSE,	"DNGVersion" },
@@ -604,7 +602,7 @@
             TIFFFieldInfo key = {0, 0, 0, 0, 0, 0, 0, 0};
             key.field_name = (char *)field_name;
             key.field_type = dt;
-            return((const TIFFFieldInfo *) bsearch(&key, 
+            return((const TIFFFieldInfo *) lsearch(&key, 
 						   tif->tif_fieldinfo, 
 						   tif->tif_nfields,
 						   sizeof(TIFFFieldInfo), 

_______________________________________________
Tiff mailing list
Tiff@remotesensing.org
http://xserve.flids.com/mailman/listinfo/tiff
