AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
March 2005

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2005.03.29 23:08 "[patch] little things", by <ron@debian.org>
2005.03.30 13:48 "Re: [patch] little things", by Andrey Kiselev

2005.03.29 23:08 "[patch] little things", by <ron@debian.org>

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