--- OLD/pnm/pnmcrop.c Thu Jan 1 00:00:00 1970 +++ NEW/pnm/pnmcrop.c Thu Jan 1 00:00:00 1970 @@ -30,8 +30,10 @@ int argn, format, backdefault, backblack; int rows, cols, row, col, newrows, newcols; int top, bottom, left, right; + int pnmcut; + int verbose; int which; - char *usage = "[-white|-black] [-left] [-right] [-top] [-bottom] [pnmfile]"; + char *usage = "[-white|-black] [-left] [-right] [-top] [-bottom] [-pnmcut] [pnmfile]"; pnm_init( &argc, argv ); @@ -39,6 +41,8 @@ backdefault = 1; which = 0; + pnmcut = 0; + verbose = 0; /* Check for flags. */ if ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { @@ -68,6 +72,14 @@ { which |= BOTTOM; } + else if ( pm_keymatch( argv[argn], "-pnmcut", 1 ) ) + { + pnmcut = 1; + } + else if ( pm_keymatch( argv[argn], "-verbose", 1 ) ) + { + verbose = 1; + } else pm_usage( usage ); ++argn; @@ -149,6 +161,8 @@ } } else right = cols - 1; + if (verbose) + { #define ending(n) (((n) > 1) ? "s" : "") if ( top > 0 ) pm_message( "cropping %d row%s off the top", top, ending(top), 0,0,0 ); @@ -158,7 +172,13 @@ pm_message( "cropping %d col%s off the left", left, ending(left), 0,0,0 ); if ( right < cols - 1 ) pm_message( "cropping %d col%s off the right", cols-1-right, ending(cols-1-right), 0,0,0 ); - +#undef ending + } + if (pnmcut) + { printf("%d %d %d %d\n",left,top,right+1-left,bottom+1-top); + } + else + { /* Now write out the new anymap. */ newcols = right - left + 1; newrows = bottom - top + 1; @@ -166,6 +186,7 @@ for ( row = top; row <= bottom; row++ ) pnm_writepnmrow( stdout, &(xels[row][left]), newcols, maxval, format, 0 ); pm_close( stdout ); + } exit( 0 ); }