Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 7589

Summary: pnmtotiff should allow TIFF file resolution to be set
Product: [Retired] Red Hat Linux Reporter: Jonathan Kamens <jik>
Component: libgrAssignee: Michael K. Johnson <johnsonm>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 1999-12-06 21:14:34 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Jonathan Kamens 1999-12-04 23:38:09 UTC
The pnmtotiff tool should allow the user to specify the resolution of the
output TIFF file.  This patch accomplishes that.

I don't know if libgr is being actively maintained by its original
creators, nor can I tell easily from the source .tar.gz file who they are.
If they are still maintaining it, could you please forward this patch to
them, in addition to including it in a later libgr redhat package?

Thank you.

--- pnm/pnmtotiff.1	1997/08/12 20:37:50	1.1
+++ pnm/pnmtotiff.1	1997/08/12 20:39:56
@@ -13,6 +13,12 @@
 .RB [ -msb2lsb | -lsb2msb ]
 .RB [ -rowsperstrip
 .IR n ]
+.RB [ -X
+.IR res |
+.B -Y
+.IR res |
+.B -R
+.IR res ]
 .RI [ pnmfile ]
 .SH DESCRIPTION
 Reads a portable anymap as input.
@@ -70,6 +76,14 @@
 strip of data in the output file.  By default, the output file has
 the number of rows per strip set to a value that will ensure each
 strip is no more than 8 kilobytes long.
+.P
+The
+.BR -X ,
+.BR -Y ,
+and
+.BR -R
+options can be used to specify the X, Y, or both resolutions of the
+input anymap, in pixels per inch.
 .SH BUGS
 This program is not self-contained.  To use it you must fetch the
 TIFF Software package listed in the OTHER.SYSTEMS file and configure
--- pnm/pnmtotiff.c	1997/08/12 20:20:23	1.1
+++ pnm/pnmtotiff.c	1997/08/12 22:21:41
@@ -62,7 +62,8 @@
     int bytesperrow;
     unsigned char* buf;
     unsigned char* tP;
-    char* usage = "[-none|-packbits|-lzw|-g3|-g4] [-msb2lsb|-lsb2msb]
[-2d] [-fill] [-predictor n] [-rowsperstrip n] [pnmfile]";
+    float x_resolution = -1, y_resolution = -1;
+    char* usage = "[-none|-packbits|-lzw|-g3|-g4] [-msb2lsb|-lsb2msb]
[-2d] [-fill] [-predictor n] [-rowsperstrip n] [-X res|-Y res|-R res]
[pnmfile]";


     pnm_init( &argc, argv );
@@ -102,7 +103,7 @@
 	    if ( predictor != 1 && predictor != 2 )
 		pm_usage( usage );
 	    }
-	else if ( pm_keymatch( argv[argn], "-rowsperstrip", 2 ) )
+	else if ( pm_keymatch( argv[argn], "-rowsperstrip", 3 ) )
 	    {
 	    ++argn;
 	    if ( argn == argc ||
@@ -111,6 +112,31 @@
 	    if ( rowsperstrip < 1 )
 		pm_usage( usage );
 	    }
+	else if ( pm_keymatch( argv[argn], "-X", 2 ) )
+	    {
+	    ++argn;
+	    if ( argn == argc || sscanf( argv[argn], "%f", &x_resolution) != 1 )
+		pm_usage( usage );
+	    if ( x_resolution < 1 )
+		pm_usage( usage );
+	    }
+	else if ( pm_keymatch( argv[argn], "-Y", 2 ) )
+	    {
+	    ++argn;
+	    if ( argn == argc || sscanf( argv[argn], "%f", &y_resolution) != 1 )
+		pm_usage( usage );
+	    if ( y_resolution < 1 )
+		pm_usage( usage );
+	    }
+	else if ( pm_keymatch( argv[argn], "-R", 2 ) )
+	    {
+	    ++argn;
+	    if ( argn == argc || sscanf( argv[argn], "%f", &x_resolution) != 1 )
+		pm_usage( usage );
+	    if ( x_resolution < 1 )
+		pm_usage( usage );
+	    y_resolution = x_resolution;
+	    }
 	else
 	    pm_usage( usage );
 	++argn;
@@ -248,6 +274,12 @@
     TIFFSetField( tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip );
     /* TIFFSetField( tif, TIFFTAG_STRIPBYTECOUNTS, rows / rowsperstrip );
*/
     TIFFSetField( tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG );
+    if ( x_resolution > 0 )
+	TIFFSetField( tif, TIFFTAG_XRESOLUTION, x_resolution );
+    if ( y_resolution > 0 )
+	TIFFSetField( tif, TIFFTAG_YRESOLUTION, y_resolution );
+    if ( x_resolution > 0 || y_resolution > 0 )
+	TIFFSetField( tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH );

     if ( chv == (colorhist_vector) 0 )
 	cht = (colorhash_table) 0;

Comment 1 Michael K. Johnson 1999-12-06 21:14:59 UTC
I've sent out a query to see if the maintainer is still maintaining libgr.
In the meantime, I've added your patch; the next RawHide should have
libgr-2.0.13-21 or later.