Package: netpbm Version: 2:10.0-8sarge3.1 Severity: wishlist Tags: patch I was experiencing a problem with my Debian machine receiving faxes. Every so often a very wide one would come though, which when scaled & printed would cause the printed fax to be impossibly small.
Turned out is was caused by the end-of-line markers in the fax data being corrupted which in turn causes several lines to be run together. Thus the G3 fax image ended up being several times wider than it should, and when this was scaled to fit onto the fax page the writing on the fax became too small to read. Corruption is not uncommon in fax data. The attached patch overcomes this by adding a -crop option to g3topbm. -crop causes the image width to be cropped to the most common line width. All lines should be the same width, so this causes the outliners to be ignored. -- System Information: Debian Release: 3.1 Architecture: i386 (i686) Kernel: Linux 2.6.17-8.1-lube-686-smp Locale: LANG=en_AU, LC_CTYPE=en_AU (charmap=ISO-8859-1) Versions of packages netpbm depends on: ii bc 1.06-15 The GNU bc arbitrary precision cal ii libc6 2.3.2.ds1-22sarge6 GNU C Library: Shared libraries an ii libjpeg62 6b-10 The Independent JPEG Group's JPEG ii libnetpbm10 2:10.0-8sarge3.1 Shared libraries for netpbm ii libpng12-0 1.2.8rel-1 PNG library - runtime ii libtiff4 3.7.2-7 Tag Image File Format (TIFF) libra ii zlib1g 1:1.2.2-4.sarge.2 compression library - runtime -- no debconf information
diff -Nur netpbm-free-10.0/pbm/g3topbm.1 netpbm-free-10.0-new/pbm/g3topbm.1 --- netpbm-free-10.0/pbm/g3topbm.1 2003-08-13 04:23:03.000000000 +1000 +++ netpbm-free-10.0-new/pbm/g3topbm.1 2007-06-20 16:17:03.000000000 +1000 @@ -4,6 +4,7 @@ g3topbm - convert a Group 3 fax file into a portable bitmap .SH SYNOPSIS .B g3topbm +.RB [ -crop ] .RB [ -kludge ] .RB [ -reversebits ] .RB [ -stretch ] @@ -14,6 +15,12 @@ .IX fax Produces a portable bitmap as output. .SH OPTIONS +.TP +.B -crop +Tells +.I g3topbm +to crop the picture at the most common column width. +Without this corrupted end-of-line markers cause wide faxes. .TP .B -kludge Tells diff -Nur netpbm-free-10.0/pbm/g3topbm.c netpbm-free-10.0-new/pbm/g3topbm.c --- netpbm-free-10.0/pbm/g3topbm.c 2007-06-20 16:01:44.000000000 +1000 +++ netpbm-free-10.0-new/pbm/g3topbm.c 2007-06-20 16:14:25.000000000 +1000 @@ -17,6 +17,7 @@ #define MAXCOLS 10800 #define MAXROWS 14400 /* up to two pages long */ +static int crop; static int endoffile = 0; static int eols; static int rawzeros; @@ -42,6 +43,7 @@ static int rawgetbit ARGS(( FILE* file )); static bit* bits[MAXROWS]; +static int col_widthcount[MAXCOLS]; int main( argc, argv ) @@ -50,12 +52,13 @@ { FILE* ifp; int argn, rows, cols, row, col, i; - char* usage = "[-kludge][-reversebits][-stretch] [g3file]"; + char* usage = "[-crop][-kludge][-reversebits][-stretch] [g3file]"; pbm_init( &argc, argv ); argn = 1; + crop = 0; kludge = 0; reversebits = 0; stretch = 0; @@ -65,6 +68,8 @@ { if ( pm_keymatch( argv[argn], "-kludge", 2 ) ) kludge = 1; + else if ( pm_keymatch( argv[argn], "-crop", 2 ) ) + crop = 1; else if ( pm_keymatch( argv[argn], "-reversebits", 2 ) ) reversebits = 1; else if ( pm_keymatch( argv[argn], "-stretch", 2 ) ) @@ -109,7 +114,8 @@ { bits[rows] = pbm_allocrow( MAXCOLS ); col = getfaxrow( ifp, rows, bits[rows] ); - fprintf(stderr, "row=%d cols=%d\n", rows, col); + if (col < MAXCOLS) + col_widthcount[col] += 1; if ( endoffile ) break; if ( !col) @@ -128,6 +134,16 @@ pm_close( ifp ); + if (crop) + { + cols = 0; + for (col = 0; col < MAXCOLS; col += 1) + { + if (col_widthcount[col] > col_widthcount[cols]) + cols = col; + } + } + pbm_writepbminit( stdout, cols, rows, 0 ); for ( row = 0; row < rows; ++row ) pbm_writepbmrow( stdout, bits[row], cols, 0 );