\ .\" This man page was generated by the Netpbm tool 'makeman' from HTML source. .\" Do not hand-hack it! If you have bug fixes or improvements, please find .\" the corresponding HTML page on the Netpbm website, generate a patch .\" against that, and send it to the Netpbm maintainer. .TH "Pnmcrop User Manual" 0 "11 March 2009" "netpbm documentation" .SH NAME pnmcrop - crop a PNM image .UN synopsis .SH SYNOPSIS \fBpnmcrop\fP [\fB-white\fP|\fB-black\fP|\fB-sides\fP] [\fB-left\fP] [\fB-right\fP] [\fB-top\fP] [\fB-bottom\fP] [\fB-margin=\fP\fIpixels\fP] [\fB-borderfile=\fP\fIfilename\fP] [\fIpnmfile\fP] .PP Minimum unique abbreviation of option is acceptable. You may use double hyphens instead of single hyphen to denote options. You may use white space in place of the equals sign to separate an option name from its value. .UN description .SH DESCRIPTION .PP This program is part of .BR Netpbm (1) . .PP \fBpnmcrop\fP reads a PBM, PGM, or PPM image as input, removes borders that are the background color, and produces the same type of image as output. .PP If you don't specify otherwise, \fBpnmcrop\fP assumes the background color is whatever color the top left and right corners of the image are and if they are different colors, something midway between them. You can specify that the background is white or black with the \fB-white\fP and \fB-black\fP options or make \fBpnmcrop\fP base its guess on all four corners instead of just two with \fB-sides\fP. .PP By default, \fBpnmcrop\fP chops off any stripe of background color it finds, on all four sides. You can tell \fBpnmcrop\fP to remove only specific borders with the \fB-left\fP, \fB-right\fP, \fB-top\fP, and \fB-bottom\fP options. .PP If you want to leave some border, use the \fB-margin\fP option. It will not only spare some of the border from cropping, but will fill in (with what \fBpnmcrop\fP considers the background color) if necessary to get up to that size. .PP If the input is a multi-image stream, \fBpnmcrop\fP processes each one independently and produces a multi-image stream as output. It chooses where to crop independently for each image. So if you start with a stream of images of the same dimensions, you may end up with images of differing dimensions. Before Netpbm 10.37 (December 2006), \fBpnmcrop\fP ignored all input images but the first. .PP If you want to chop a specific amount off the side of an image, use \fBpamcut\fP. .PP If you want to add different borders after removing the existing ones, use \fBpnmcat\fP or \fBpamcomp\fP. .UN options .SH OPTIONS .TP \fB-white\fP Take white to be the background color. \fBpnmcrop\fP removes borders which are white. .TP \fB-black\fP Take black to be the background color. \fBpnmcrop \fP removes borders which are black. .TP \fB-sides\fP Determine the background color from the colors of the four corners of the input image. \fBpnmcrop\fP removes borders which are of the background color. .sp If at least three of the four corners are the same color, \fBpnmcrop \fP takes that as the background color. If not, \fBpnmcrop\fP looks for two corners of the same color in the following order, taking the first found as the background color: top, left, right, bottom. If all four corners are different colors, \fBpnmcrop\fP assumes an average of the four colors as the background color. .sp The \fB-sides\fP option slows \fBpnmcrop\fP down, as it reads the entire image to determine the background color in addition to the up to three times that it would read it without \fB-sides\fP. .TP \fB-left\fP Remove any left border. .TP \fB-right\fP Remove any right border. .TP \fB-top\fP Remove any top border. .TP \fB-bottom\fP Remove any bottom border. .TP \fB-margin=\fP\fIpixels\fP Leave \fIpixels\fP pixels of border. Expand the border to this size if necessary. .sp This option was new in Netpbm 10.29 (August 2005). .TP \fB-borderfile=\fP\fIfilename\fP Use the image in the file named \fIfilename\fP instead of the input image to determine where the borders of the input image are and the background color. .sp Without this option, \fBpnmcrop\fP examines the input image and figures out what part of the image is border and what part is foreground (not border), as well as the background color. With this option, \fBpnmcrop\fP finds the borders in one image, then uses the those four border sizes (left, right, top, bottom) in cropping a different image. Furthermore, if you use \fB-margin\fP to add borders, the color of those borders is the background color \fBpnmcrop\fP detects in the border file. .sp The point of this is that you may want to help \fBpnmcrop\fP to come to a different conclusion as to where the borders are and what the background color is by preprocessing the input image. For example, consider an image that has speckles of noise in its borders. \fBpnmcrop\fP isn't smart enough to recognize these as noise; it sees them as foreground image. So \fBpnmcrop\fP considers most of your borders to be foreground and does not crop them off as you want. To fix this, run the image through a despeckler such as \fBpbmclean\fP and tell \fBpnmcrop\fP to use the despeckled version of the image as the \fB-borderfile\fP image, but the original speckled version as the input image. That way, you crop the borders, but retain the true foreground image, speckles and all. .sp This option was new in Netpbm 10.29 (August 2005). .sp Before Netpbm 10.46 (March 2009), the original image and not the border file determines the background color. \fBpnmcrop\fP fails if there is no apparent background color in the original image (i.e. the corners of the image don't have a common color). .TP \fB-verbose\fP Print on Standard Error information about the processing, including exactly how much is being cropped off of which sides. .UN seealso .SH SEE ALSO .BR pamcut (1) , .BR pamfile (1) , .BR pnm (5) .UN author .SH AUTHOR Copyright (C) 1989 by Jef Poskanzer.