Bug 7589 - pnmtotiff should allow TIFF file resolution to be set
pnmtotiff should allow TIFF file resolution to be set
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: libgr (Show other bugs)
6.1
All Linux
medium Severity medium
: ---
: ---
Assigned To: Michael K. Johnson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-12-04 18:38 EST by Jonathan Kamens
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 1999-12-06 16:14:34 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jonathan Kamens 1999-12-04 18:38:09 EST
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 16:14:59 EST
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.

Note You need to log in before you can comment on or make changes to this bug.