summaryrefslogtreecommitdiffstats
path: root/upstream/opensuse-leap-15-6/man1/pnmcrop.1
blob: 43f14145faa817e06e3dd8b043a3ff2a6670c25a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
\
.\" 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 "31 December 2016" "netpbm documentation"

.SH NAME

pnmcrop - crop a Netpbm 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-verbose\fP]

[\fB-margin=\fP\fIpixels\fP]

[\fB-closeness=\fP\fIcloseness_percent\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)\c
\&.
.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-closeness=\fP\fIcloseness_percent\fP
.sp
Any color in the image that is at least this close to the operative
background color is considered to be background.
.sp
You can use this if the image has borders that vary slightly in color, such
as would be the case in a photograph.  Consider a photograph against a white
screen.  The color of the screen varies slightly with shading and dirt and
such, but is still quite distinct in color from the subject of the
photograph.  \fBpnmcrop\fP will choose some particular shade as the
background color and if you specify an appropriate \fB-closeness\fP value, it
will correctly identify all of the screen as background and crop it off.
.sp
To implement more complex rules for identifying background, use
\fB-borderfile\fP.
.sp
The default is zero, which means a pixel's color must exactly match the
background color for the pixel to be considered part of a background border.
.sp
This option was new in Netpbm 10.78 (March 2017).  With older Netpbm,
colors must match exactly.

.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)\c
\&,
.BR "pamfile" (1)\c
\&,
.BR "pnm" (5)\c
\&

.UN author
.SH AUTHOR

Copyright (C) 1989 by Jef Poskanzer.
.SH DOCUMENT SOURCE
This manual page was generated by the Netpbm tool 'makeman' from HTML
source.  The master documentation is at
.IP
.B http://netpbm.sourceforge.net/doc/pnmcrop.html
.PP