1Pnmcrop User Manual(0) Pnmcrop User Manual(0)
2
3
4
6 pnmcrop - crop a Netpbm image
7
8
10 pnmcrop
11
12 [-white|-black|-sides]
13
14 [-left]
15
16 [-right]
17
18 [-top]
19
20 [-bottom]
21
22 [-verbose]
23
24 [-margin=pixels]
25
26 [-closeness=closeness_percent]
27
28 [-borderfile=filename]
29
30 [pnmfile]
31
32 Minimum unique abbreviation of option is acceptable. You may use dou‐
33 ble hyphens instead of single hyphen to denote options. You may use
34 white space in place of the equals sign to separate an option name from
35 its value.
36
37
39 This program is part of Netpbm(1).
40
41 pnmcrop reads a PBM, PGM, or PPM image as input, removes borders that
42 are the background color, and produces the same type of image as out‐
43 put.
44
45 If you don't specify otherwise, pnmcrop assumes the background color is
46 whatever color the top left and right corners of the image are and if
47 they are different colors, something midway between them. You can
48 specify that the background is white or black with the -white and
49 -black options or make pnmcrop base its guess on all four corners
50 instead of just two with -sides.
51
52 By default, pnmcrop chops off any stripe of background color it finds,
53 on all four sides. You can tell pnmcrop to remove only specific bor‐
54 ders with the -left, -right, -top, and -bottom options.
55
56 If you want to leave some border, use the -margin option. It will not
57 only spare some of the border from cropping, but will fill in (with
58 what pnmcrop considers the background color) if necessary to get up to
59 that size.
60
61 If the input is a multi-image stream, pnmcrop processes each one inde‐
62 pendently and produces a multi-image stream as output. It chooses
63 where to crop independently for each image. So if you start with a
64 stream of images of the same dimensions, you may end up with images of
65 differing dimensions. Before Netpbm 10.37 (December 2006), pnmcrop
66 ignored all input images but the first.
67
68 If you want to chop a specific amount off the side of an image, use
69 pamcut.
70
71 If you want to add different borders after removing the existing ones,
72 use pnmcat or pamcomp.
73
74
75
77 -white Take white to be the background color. pnmcrop removes borders
78 which are white.
79
80
81 -black Take black to be the background color. pnmcrop removes borders
82 which are black.
83
84
85 -sides Determine the background color from the colors of the four cor‐
86 ners of the input image. pnmcrop removes borders which are of
87 the background color.
88
89 If at least three of the four corners are the same color, pnm‐
90 crop takes that as the background color. If not, pnmcrop looks
91 for two corners of the same color in the following order, taking
92 the first found as the background color: top, left, right, bot‐
93 tom. If all four corners are different colors, pnmcrop assumes
94 an average of the four colors as the background color.
95
96 The -sides option slows pnmcrop down, as it reads the entire
97 image to determine the background color in addition to the up to
98 three times that it would read it without -sides.
99
100
101 -left Remove any left border.
102
103
104 -right Remove any right border.
105
106
107 -top Remove any top border.
108
109
110 -bottom
111 Remove any bottom border.
112
113
114 -margin=pixels
115 Leave pixels pixels of border. Expand the border to this size
116 if necessary.
117
118 This option was new in Netpbm 10.29 (August 2005).
119
120
121 -closeness=closeness_percent
122
123 Any color in the image that is at least this close to the opera‐
124 tive background color is considered to be background.
125
126 You can use this if the image has borders that vary slightly in
127 color, such as would be the case in a photograph. Consider a
128 photograph against a white screen. The color of the screen
129 varies slightly with shading and dirt and such, but is still
130 quite distinct in color from the subject of the photograph.
131 pnmcrop will choose some particular shade as the background
132 color and if you specify an appropriate -closeness value, it
133 will correctly identify all of the screen as background and crop
134 it off.
135
136 To implement more complex rules for identifying background, use
137 -borderfile.
138
139 The default is zero, which means a pixel's color must exactly
140 match the background color for the pixel to be considered part
141 of a background border.
142
143 This option was new in Netpbm 10.78 (March 2017). With older
144 Netpbm, colors must match exactly.
145
146
147 -borderfile=filename
148 Use the image in the file named filename instead of the input
149 image to determine where the borders of the input image are and
150 the background color.
151
152 Without this option, pnmcrop examines the input image and fig‐
153 ures out what part of the image is border and what part is fore‐
154 ground (not border), as well as the background color. With this
155 option, pnmcrop finds the borders in one image, then uses the
156 those four border sizes (left, right, top, bottom) in cropping a
157 different image. Furthermore, if you use -margin to add bor‐
158 ders, the color of those borders is the background color pnmcrop
159 detects in the border file.
160
161 The point of this is that you may want to help pnmcrop to come
162 to a different conclusion as to where the borders are and what
163 the background color is by preprocessing the input image. For
164 example, consider an image that has speckles of noise in its
165 borders. pnmcrop isn't smart enough to recognize these as
166 noise; it sees them as foreground image. So pnmcrop considers
167 most of your borders to be foreground and does not crop them off
168 as you want. To fix this, run the image through a despeckler
169 such as pbmclean and tell pnmcrop to use the despeckled version
170 of the image as the -borderfile image, but the original speckled
171 version as the input image. That way, you crop the borders, but
172 retain the true foreground image, speckles and all.
173
174 This option was new in Netpbm 10.29 (August 2005).
175
176 Before Netpbm 10.46 (March 2009), the original image and not the
177 border file determines the background color. pnmcrop fails if
178 there is no apparent background color in the original image
179 (i.e. the corners of the image don't have a common color).
180
181
182 -verbose
183 Print on Standard Error information about the processing,
184 including exactly how much is being cropped off of which sides.
185
186
187
188
190 pamcut(1), pamfile(1), pnm(1)
191
192
194 Copyright (C) 1989 by Jef Poskanzer.
195
197 This manual page was generated by the Netpbm tool 'makeman' from HTML
198 source. The master documentation is at
199
200 http://netpbm.sourceforge.net/doc/pnmcrop.html
201
202netpbm documentation 31 December 2016 Pnmcrop User Manual(0)