Plan 9 from Bell Labs’s /usr/web/sources/contrib/pac/sys/doc/netpbm/ms/pnmcrop.ms

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


.TL
Pnmcrop User Manual
.SH 1
pnmcrop
.LP
Updated: 06 August 2005
.br
Table Of Contents
.SH 2
NAME
.LP
pnmcrop - crop a PNM image
.SH 2
SYNOPSIS
.LP
\fBpnmcrop\fR
[\fB-white\fR|\fB-black\fR|\fB-sides\fR]
[\fB-left\fR]
[\fB-right\fR]
[\fB-top\fR]
[\fB-bottom\fR]
[\fB-margin=\fR\fIpixels\fR]
[\fB-borderfile=\fR\fIfilename\fR]
[\fIpnmfile\fR]
.LP
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.
.SH 2
DESCRIPTION
.LP
.LP
This program is part of Netpbm.
.LP
\fBpnmcrop\fR 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.
.LP
If you don't specify otherwise, \fBpnmcrop\fR 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\fR and \fB-black\fR options or make
\fBpnmcrop\fR base its guess on all four corners instead of just two
with \fB-sides\fR.
.LP
By default, \fBpnmcrop\fR chops off any stripe of background color
it finds, on all four sides.  You can tell \fBpnmcrop\fR to remove
only specific borders with the \fB-left\fR, \fB-right\fR,
\fB-top\fR, and \fB-bottom\fR options.
.LP
If you want to leave some border, use the \fB-margin\fR option.  It
will not only spare some of the border from cropping, but will fill in
(with what \fBpnmcrop\fR considers the background color) if necessary
to get up to that size.
.LP
If you want to chop a specific amount off the side of an image, use
\fBpamcut\fR.
.LP
If you want to add different borders after removing the existing
ones, use \fBpnmcat\fR or \fBpamcomp\fR.
.SH 2
OPTIONS
.LP
.RS
.IP "\fB-white\fR"
Take white to be the background color.  \fBpnmcrop\fR removes
borders which are white.
.IP "\fB-black\fR"
Take black to be the background color.  \fBpnmcrop \fR removes
borders which are black.
.IP "\fB-sides\fR"
Determine the background color from the colors of the four corners
of the input image.  \fBpnmcrop\fR removes borders which are of the
background color.
.LP
If at least three of the four corners are the same color,
\fBpnmcrop \fR takes that as the background color.  If not,
\fBpnmcrop\fR 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\fR assumes an average of the four colors as the background
color.
.LP
The \fB-sides\fR option slows \fBpnmcrop\fR 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\fR.
.IP "\fB-left\fR"
Remove any left border.
.IP "\fB-right\fR"
Remove any right border.
.IP "\fB-top\fR"
Remove any top border.
.IP "\fB-bottom\fR"
Remove any bottom border.
.IP "\fB-margin=\fR\fIpixels\fR"
Leave \fIpixels\fR pixels of border.  Expand the border to this size
if necessary.
.LP
This option was new in Netpbm 10.29 (August 2005).
.IP "\fB-borderfile=\fR\fIfilename\fR"
Use the image in the file named \fIfilename\fR instead of the input
image to determine where the borders of the input image are.
.LP
Without this option, \fBpnmcrop\fR examines the input image and
figures out what part of the image is border and what part is
foreground (not border).  With this option, \fBpnmcrop\fR finds the
borders in one image, then uses the those four border sizes (left,
right, top, bottom) in cropping a different image.
.LP
The point of this is that you may want to help \fBpnmcrop\fR to
come to a different conclusion as to where the border are by
preprocessing the input image.  For example, consider an image that
has speckles of noise in its borders.  \fBpnmcrop\fR isn't smart
enough to recognize these as noise; it sees them as foreground image.
So \fBpnmcrop\fR 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\fR and tell \fBpnmcrop\fR
to use the despeckled version of the image as the \fB-borderfile\fR
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.
.LP
This option was new in Netpbm 10.29 (August 2005).
.IP "\fB-verbose\fR"
Print on Standard Error information about the processing,
including exactly how much is being cropped off of which sides.
.RE
.SH 2
SEE ALSO
.LP
\fBpamcut\fR,
\fBpamfile\fR,
\fBpnm\fR
.SH 2
AUTHOR
.LP
Copyright (C) 1989 by Jef Poskanzer.
.br
\l'5i'
.SH 2
Table Of Contents
.LP
.IP \(bu
SYNOPSIS
.IP \(bu
DESCRIPTION
.IP \(bu
OPTIONS
.IP \(bu
SEE ALSO
.IP \(bu
AUTHOR
.LP

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.