summary refs log tree commit diff
path: root/pamcut.html
blob: 1bbaa0da886158d5fdceb31aef26e563781fb313 (plain) (blame)
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
222
223
224
225
226
227
228
229
230
231
232
233
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN">
<html><head><title>Pamcut User Manual</title></head>
<body>
<h1>pamcut</h1>
Updated: 04 October 2019
<br>
<a href="#index">Table Of Contents</a>

<h2>NAME</h2>
pamcut - cut a rectangle out of a PAM, PBM, PGM, or PPM image

<h2 id="synopsis">SYNOPSIS</h2>

<b>pamcut</b>

[<b>-left </b><i>colnum</i>]

[<b>-right </b><i>colnum</i>]

[<b>-top </b><i>rownum</i>]

[<b>-bottom </b><i>rownum</i>]

[<b>-width </b><i>cols</i>]

[<b>-height </b><i>rows</i>]

[<b>-pad</b>]

[<b>-cropleft </b><i>numcols</i>]

[<b>-cropright </b><i>numcols</i>]

[<b>-croptop </b><i>numrows</i>]

[<b>-cropbottom </b><i>numrows</i>]

[<b>-verbose</b>]

[<i>left</i> <i>top</i> <i>width</i> <i>height</i>]

[<i>pnmfile</i>]

<p>Minimum unique abbreviations of option are 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.

<h2 id="description">DESCRIPTION</h2>

<p>This program is part of <a href="index.html">Netpbm</a>.

<p><b>pamcut</b> reads a PAM, PBM, PGM, or PPM image as input and
extracts the specified rectangle, and produces the same kind of image
as output.

<p>You can specify either the rectangle to cut out and keep or specify the
edges to crop off and discard, or a combination.

<p>To request edges be cropped off, use options <b>-cropleft</b>,
<b>-cropright</b>, <b>-croptop</b>, and <b>-cropbottom</b> to indicate how many
rows or columns to discard.

<p>For example, <b>-cropleft=50 -cropright=200</b> means to discard the
leftmost 50 and rightmost 200 columns.

<p>To specify the rectangle to keep, use <b>-left</b>, <b>-right</b>,
<b>-top</b>, <b>-bottom</b>, <b>-width</b>, <b>-height</b>, and <b>-pad</b>
options.

<p>For example, <b>-left=50 -right=200</b> means to keep the 150 columns
between Columns 50 and 200 inclusive.

<p>You can code any mixture of the options.  What you don't specify defaults.
Those defaults are in favor of minimal cutting and in favor of cutting the
right and bottom edges off.  It is an error to overspecify, i.e. to specify
all three of <b>-left</b>, <b>-right</b>, and <b>-width</b> or <b>-top</b>,
<b>-bottom</b>, and <b>-height</b> or <b>right</b> as well as
<b>-cropright</b>.

<p>There is an older way to specify the rectangle to keep: positional
arguments.  Arguments were the only way available before July 2000, but you
should not use them in new applications.  Options are easier to remember and
read, more expressive, and allow you to use defaults.

<p>If you use both options and arguments, the two specifications get
mixed in an unspecified way.

<p>To use arguments, specify all four of the <i>left</i>, <i>top</i>,
<i>width</i>, and <i>height</i> arguments.  <i>left</i> and <i>top</i> have
the same effect as specifying them as the argument of a <b>-left</b> or
<b>-top</b> option, respectively.  <i>width</i> and <i>height</i> have the
same effect as specifying them as the argument of a <b>-width</b> or
<b>-height</b> option, respectively, where they are positive.  Where they are
not positive, they have the same effect as specifying one less than the value
as the argument to a <b>-right</b> or <b>-bottom</b> option, respectively.
(E.g. <i>width</i> = 0 makes the cut go all the way to the right edge).
Before July 2000, negative numbers were not allowed for <i>width</i> and
<i>height</i>.

<p>Input is from Standard Input if you don't specify the input file
<i>pnmfile</i>.

<p>Output is to Standard Output.

<p><b>pamcut</b> works on a multi-image stream.  It cuts each image in the
stream independently and produces a multi-image stream output.  Before
Netpbm 10.32 (March 2006), it ignored all but the first image in the stream.

<p>If you are splitting a single image into multiple same-size images,
<b>pamdice</b> is faster and easier than running <b>pamcut</b>
multiple times.

<p><b>pamcomp</b> is also useful for cutting and padding an image to a
certain size.  You create a background image of the desired frame
dimensions and overlay the subject image on it.

<h2 id="options">OPTIONS</h2>

<p>In addition to the options common to all programs based on libnetpbm
(most notably <b>-quiet</b>, see <a href="index.html#commonoptions">
Common Options</a>), <b>pamcut</b> recognizes the following
command line options:

<dl compact>
<dt><b>-left=</b><i>colnum</i>

<dd>The column number of the leftmost column to be in the output.
Columns left of this get cut out.  If a nonnegative number, it refers
to columns numbered from 0 at the left, increasing to the right.  If
negative, it refers to columns numbered -1 at the right, decreasing to
the left.

<dt><b>-right=</b><i>colnum</i>

<dd>The column number of the rightmost column to be in the output,
numbered the same as for <b>-left.</b>  Columns to the right of this
get cut out.

<dt><b>-top=</b><i>rownum</i>

<dd>The row number of the topmost row to be in the output.  Rows above
this get cut out.  If a nonnegative number it refers to rows numbered
from 0 at the top, increasing downward.  If negative, it refers to
columns numbered -1 at the bottom, decreasing upward.

<dt><b>-bottom=</b><i>rownum</i>

<dd>The row number of the bottom-most row to be in the output,
numbered the same as for <b>-top</b>.  Rows below this get cut out.

<dt><b>-width=</b><i>cols</i>

<dd>The number of columns to be in the output.  Must be positive.

<dt><b>-height=</b><i>rows</i>

<dd>The number of rows to be in the output.  Must be positive.

<dt><b>-cropleft</b>
<dt><b>-cropright</b>
<dt><b>-croptop</b>
<dt><b>-cropbottom</b>

<dd>These options tell how many rows or columns to crop from the left,
right, top, or bottom edges, respectively.

<p>The value must not be negative.

<p>These option were new in Netpbm 10.85 (December 2018).  Before that, you
can achieve the same thing with <b>-left</b>, <b>top</b>, and negative values
for <b>-right</b> and <b>-bottom</b>.  Remember to subtract one in the latter
case; e.g. the equivalent of <b>-cropright=1</b> is <b>-right=-2</b>.
  
<dt><b>-pad</b>

<dd>If the rectangle you specify is not entirely within the input
image, <b>pamcut</b> fails unless you also specify <b>-pad</b>.  In
that case, it pads the output with black up to the edges you specify.
You can use this option if you need to have an image of certain
dimensions and have an image of arbitrary dimensions.

<p><b>pnmpad</b> also adds borders to an image, but you specify their
width directly.

<p><b>pamcomp</b> does a more general form of this padding.  Create a
background image of the frame dimensions and overlay the subject image
on it.  You can use options to have the subject image in the center of
the frame or against any edge and make the padding any color (the padding
color is the color of the background image).

<dt><b>-verbose</b>

<dd>
Print information about the processing to Standard Error.

</dl>
<h2 id="seealso">SEE ALSO</h2>

<b><a href="pnmcrop.html">pnmcrop</a></b>,
<b><a href="pamdice.html">pamdice</a></b>,
<b><a href="pamcomp.html">pamcomp</a></b>,
<b><a href="pnmpad.html">pnmpad</a></b>,
<b><a href="pamcat.html">pamcat</a></b>,
<b><a href="pgmslice.html">pgmslice</a></b>,
<b><a href="pnm.html">pnm</a></b>

<h2 id="history">HISTORY</h2>

<p><b>pamcut</b> was derived from <b>pnmcut</b> in Netpbm 9.20 (May 2001).
It was the first Netpbm program adapted to the new PAM format and programming
library.

<p>The predecessor <b>pnmcut</b> was one of the oldest tools in the Netpbm
package.


<h2 id="author">AUTHOR</h2>

Copyright (C) 1989 by Jef Poskanzer.

<hr>
<h2 id="index">Table Of Contents</h2>
<ul>
<li><a href="#synopsis">SYNOPSIS</a>
<li><a href="#description">DESCRIPTION</a>
<li><a href="#options">OPTIONS</a>
<li><a href="#seealso">SEE ALSO</a>
<li><a href="#history">HISTORY</a>
<li><a href="#author">AUTHOR</a>
</ul>
</body>
</html>