1Pnmcrop User Manual(0) Pnmcrop User Manual(0)
2
3
4
6 pnmcrop - crop a PNM image
7
8
10 pnmcrop
11
12 [-white|-black|-sides]
13
14 [-left]
15
16 [-right]
17
18 [-top]
19
20 [-bottom]
21
22 [-margin=pixels]
23
24 [-borderfile=filename]
25
26 [pnmfile]
27
28
30 This program is part of Netpbm(1).
31
32 pnmcrop reads a PBM, PGM, or PPM image as input, removes borders that
33 are the background color, and produces the same type of image as out‐
34 put.
35
36 If you don't specify otherwise, pnmcrop assumes the background color is
37 whatever color the top left and right corners of the image are and if
38 they are different colors, something midway between them. You can
39 specify that the background is white or black with the -white and
40 -black options or make pnmcrop base its guess on all four corners
41 instead of just two with -sides.
42
43 By default, pnmcrop chops off any stripe of background color it finds,
44 on all four sides. You can tell pnmcrop to remove only specific bor‐
45 ders with the -left, -right, -top, and -bottom options.
46
47 If you want to leave some border, use the -margin option. It will not
48 only spare some of the border from cropping, but will fill in (with
49 what pnmcrop considers the background color) if necessary to get up to
50 that size.
51
52 If the input is a multi-image stream, pnmcrop processes each one inde‐
53 pendently and produces a multi-image stream as output. It chooses
54 where to crop independently for each image. So if you start with a
55 stream of images of the same dimensions, you may end up with images of
56 differing dimensions. Before Netpbm 10.37 (December 2006), pnmcrop
57 ignored all input images but the first.
58
59 If you want to chop a specific amount off the side of an image, use
60 pamcut.
61
62 If you want to add different borders after removing the existing ones,
63 use pnmcat or pamcomp.
64
65
67 Minimum unique abbreviation of option is acceptable. You may use dou‐
68 ble hyphens instead of single hyphen to denote options. You may use
69 white space in place of the equals sign to separate an option name from
70 its value.
71
72
73
74 -white Take white to be the background color. pnmcrop removes borders
75 which are white.
76
77
78 -black Take black to be the background color. pnmcrop removes borders
79 which are black.
80
81
82 -sides Determine the background color from the colors of the four cor‐
83 ners of the input image. pnmcrop removes borders which are of
84 the background color.
85
86 If at least three of the four corners are the same color, pnm‐
87 crop takes that as the background color. If not, pnmcrop looks
88 for two corners of the same color in the following order, taking
89 the first found as the background color: top, left, right, bot‐
90 tom. If all four corners are different colors, pnmcrop assumes
91 an average of the four colors as the background color.
92
93 The -sides option slows pnmcrop down, as it reads the entire
94 image to determine the background color in addition to the up to
95 three times that it would read it without -sides.
96
97
98 -left Remove any left border.
99
100
101 -right Remove any right border.
102
103
104 -top Remove any top border.
105
106
107 -bottom
108 Remove any bottom border.
109
110
111 -margin=pixels
112 Leave pixels pixels of border. Expand the border to this size
113 if necessary.
114
115 This option was new in Netpbm 10.29 (August 2005).
116
117
118 -borderfile=filename
119 Use the image in the file named filename instead of the input
120 image to determine where the borders of the input image are.
121
122 Without this option, pnmcrop examines the input image and fig‐
123 ures out what part of the image is border and what part is fore‐
124 ground (not border). With this option, pnmcrop finds the bor‐
125 ders in one image, then uses the those four border sizes (left,
126 right, top, bottom) in cropping a different image.
127
128 The point of this is that you may want to help pnmcrop to come
129 to a different conclusion as to where the border are by prepro‐
130 cessing the input image. For example, consider an image that
131 has speckles of noise in its borders. pnmcrop isn't smart
132 enough to recognize these as noise; it sees them as foreground
133 image. So pnmcrop considers most of your borders to be fore‐
134 ground and does not crop them off as you want. To fix this, run
135 the image through a despeckler such as pbmclean and tell pnmcrop
136 to use the despeckled version of the image as the -borderfile
137 image, but the original speckled version as the input image.
138 That way, you crop the borders, but retain the true foreground
139 image, speckles and all.
140
141 This option was new in Netpbm 10.29 (August 2005).
142
143
144 -verbose
145 Print on Standard Error information about the processing,
146 including exactly how much is being cropped off of which sides.
147
148
149
150
152 pamcut(1), pamfile(1), pnm(1)
153
154
156 Copyright (C) 1989 by Jef Poskanzer.
157
158
159
160netpbm documentation 30 November 2006 Pnmcrop User Manual(0)