2011.03.26 11:15 "[Tiff] [PATCH] setting other directories in tiffset", by Jürgen E. Fischer

2011.03.26 11:15 "[Tiff] [PATCH] setting other directories in tiffset", by Jürgen E. Fischer

Hi there,

the attached patch adds options to modify other directories than the first with tiffset.

Jürgen

--

Jürgen E. Fischer         norBIT GmbH               Tel. +49-4931-918175-20
Dipl.-Inf. (FH)           Rheinstraße 13            Fax. +49-4931-918175-50

Software Engineer         D-26506 Norden               http://www.norbit.de

--

norBIT Gesellschaft fuer Unternehmensberatung und Informationssysteme mbH Rheinstrasse 13, 26506 Norden

GF: Jelto Buurman, HR: Amtsgericht Emden, HRB 5502

? tiffset-tiff-4.0.0beta6.diff
? tiffset.diff
Index: man/tiffset.1
===================================================================
RCS file: /cvs/maptools/cvsroot/libtiff/man/tiffset.1,v
retrieving revision 1.4
diff -u -r1.4 tiffset.1

--- man/tiffset.1       3 Dec 2009 19:27:55 -0000       1.4
+++ man/tiffset.1       26 Mar 2011 11:12:25 -0000

@@ -41,9 +41,15 @@
 header to a specified value.
 .SH OPTIONS
 .TP
+.BI \-d " dirnumber"
+change the current directory (starting at 0).
+.TP
 .BI \-s " tagnumber" "\fR [\fP" " count" "\fR ]\fP" " value ..."
 Set the value of the named tag to the value or values specified.
 .TP
+.BI \-sd " diroffset"
+change the current directory by offset.
+.TP
 .BI \-sf " tagnumber filename"
 Set the value of the tag to the contents of filename. This option is
 supported for ASCII tags only.
@@ -72,6 +78,14 @@
 tiffset \-s 283 300.0 a.tif
 .fi
 .RE
+.PP

+Set the photometric interpretation of the third page of a.tif to +min-is-black (ie. inverts it):

+.RS
+.nf
+tiffset -d 2 -s 262 1 a.tif
+.fi
+.RE
 .SH "SEE ALSO"
 .BR tiffdump (1),
 .BR tiffinfo (1),
Index: tools/tiffset.c
===================================================================
RCS file: /cvs/maptools/cvsroot/libtiff/tools/tiffset.c,v
retrieving revision 1.15
diff -u -r1.15 tiffset.c

--- tools/tiffset.c     6 Jul 2010 14:30:38 -0000       1.15
+++ tools/tiffset.c     26 Mar 2011 11:12:25 -0000

@@ -41,6 +41,8 @@
 "usage: tiffset [options] filename",
 "where options are:",
 " -s <tagname> [count] <value>... set the tag value",
+" -d <dirno> set the directory",
+" -sd <diroff> set the subdirectory",
 " -sf <tagname> <filename> read the tag value from file (for ASCII tags only)",
 NULL
 };
@@ -86,6 +88,24 @@
         return 2;

     for( arg_index = 1; arg_index < argc-1; arg_index++ ) {
+       if (strcmp(argv[arg_index],"-d") == 0 && arg_index < argc-2) {
+           arg_index++;
+           if( TIFFSetDirectory(tiff, atoi(argv[arg_index]) ) != 1 )
+            {
+               fprintf( stderr, "Failed to set directory=%s\n", argv[arg_index] );
+               return 6;
+            }
+           arg_index++;
+       }
+       if (strcmp(argv[arg_index],"-sd") == 0 && arg_index < argc-2) {
+           arg_index++;
+           if( TIFFSetSubDirectory(tiff, atoi(argv[arg_index]) ) != 1 )
+            {
+               fprintf( stderr, "Failed to set sub directory=%s\n", argv[arg_index] );
+               return 7;
+            }
+           arg_index++;
+       }
         if (strcmp(argv[arg_index],"-s") == 0 && arg_index < argc-3) {

             const TIFFField *fip;
             const char *tagname;