summaryrefslogtreecommitdiffstats
path: root/upstream/mageia-cauldron/man1/pnmpad.1
blob: bfa58cb4874e90531b530148e9df19ab454e9626 (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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
\
.\" 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 "Pnmpad User Manual" 0 "25 December 2021" "netpbm documentation"

.SH NAME

pnmpad - add borders to a PNM image

.UN synopsis
.SH SYNOPSIS

\fBpnmpad \fP
[\fB-white\fP|\fB-black\fP]
[\fB-width=\fP\fIpixels\fP]
[\fB-halign=\fP\fIratio\fP]
[\fB-mwidth=\fP\fIpixels\fP]
[\fB-left=\fP\fIpixels\fP]
[\fB-right=\fP\fIpixels\fP]
[\fB-height=\fP\fIpixels\fP]
[\fB-valign=\fP\fIratio\fP]
[\fB-mheight=\fP\fIpixels\fP]
[\fB-top=\fP\fIpixels\fP]
[\fB-bottom=\fP\fIpixels\fP]
[\fB-reportonly\fP]
[\fB-verbose\fP]
[\fIpnmfile\fP]


.UN description
.SH DESCRIPTION
.PP
This program is part of
.BR "Netpbm" (1)\c
\&.
.PP
\fBpnmpad\fP reads a PNM image as input and outputs a PNM image
that is the input image plus black or white borders of the sizes
specified.
.PP
If you just need to convert an image to a certain size regardless
of the original dimensions, \fBpamcut\fP with the \fB-pad\fP option
may be a better choice.
.PP
\fBpnmmargin\fP does essentially the same thing, but allows you to
add borders of any color and requires all four borders to be the same
size.
.PP
You can use \fBpamcomp\fP to add borders of any content - solid color,
  pattern, or whatever.  For example, if you wanted to add 10 pixels of red
  borders to the top and bottom of a 100x100 image, you could create a
  100x120 red image (e.g. with \fBppmmake\fP) and then use \fBpamcomp\fP
  to insert your 100x100 image into the center of it.
  

.UN options
.SH OPTIONS
.PP
In addition to the options common to all programs based on libnetpbm
(most notably \fB-quiet\fP, see 
.UR index.html#commonoptions
 Common Options
.UE
\&), \fBpnmpad\fP recognizes the following
command line options:
.PP
All options can be abbreviated to their shortest unique prefix.  You
may use two hyphens instead of one to designate an option.  You may
use either white space or an equals sign between an option name and
its value.


.TP
\fB-white\fP
.TP
\fB-black\fP
Set pad color.  Default is \fB-black\fP.

.TP
\fB-left=\fP\fIpixels\fP
.TP
\fB-right=\fP\fIpixels\fP
.TP
\fB-width=\fP\fIwidth\fP
.TP
\fB-halign=\fP\fIratio\fP
.TP
\fB-mwidth=\fP\fIpixels\fP
Specify amount of left and right padding in pixels.
.sp
\fB-left\fP and \fB-right\fP directly specify the amount of
padding added to the left and right sides, respectively, of the image.
.sp
Alternatively, you can specify \fB-width\fP and just one of
\fB-left\fP and \fB-right\fP and \fBpnmpad\fP calculates the required
padding on the other side to make the output \fIwidth\fP pixels wide.  If
the \fB-width\fP value is less than the width of the input image plus the
specified padding, \fBpnmpad\fP ignores \fB-width\fP.
.sp
If you specify all three of \fB-width\fP, \fB-left\fP, and
\fB-right\fP, you must ensure that the \fB-left\fP and \fB-right\fP
padding are sufficient to make the image at least as wide as
\fB-width\fP specifies.  Otherwise, \fBpnmpad\fP fails.
.sp
When you specify \fB-width\fP without \fB-left\fP or
\fB-right\fP, and \fB-width\fP is larger than the input image,
\fBpnmpad\fP chooses left and right padding amounts in a certain
ratio.  That ratio defaults to half, but you can set it to anything
(from 0 to 1) with the \fB-halign\fP option.  If the input image is
already at least as wide as \fB-width\fP specifies, \fBpnmpad\fP
adds no padding.
.sp
Common values for \fB-halign\fP are:

.TP
\fB0.0\fP 
left aligned

.TP
\fB0.5\fP 
center aligned (default)

.TP
\fB1.0\fP 
right aligned

.sp
\fB-mwidth=\fP\fIpixels\fP says to pad to a multiple of
\fIpixels\fP pixels.  E.g. if \fIpixels\fP is 10, the output image width
will be a multiple of 10 pixels.  \fBpnmpad\fP adds to whatever padding the
other options say to do to get to this multiple.  It divides that padding
between the left and right sides of the image to maintain the ratio the other
options produce.  E.g. if you say \fB-left=10 -right=10 -mwidth=50\fP with a
100-pixel image, you end up with a 150-pixel image with the extra padding
split evenly between left and right for a total of 25 pixels of padding
on the left and 25 on the right.  If the other options indicate no
padding, \fBpnmpad\fP adds padding in the ratio specified by \fB-halign\fP
and if \fB-halign\fP is not specified, equally on both sides.
.sp
Before Netpbm 10.97 (December 2021), \fBpnmpad\fP does not allow
\fB-halign\fP with \fB-mwidth\fP and adds padding only on the right
when \fB-mwidth\fP is specified and the other options indicate no padding.
.sp
Before Netpbm 10.72 (September 2015), there is no \fB-mwidth\fP.
.sp
Before Netpbm 10.23 (July 2004), \fBpnmpad\fP did not allow the
\fB-left\fP or \fB-right\fP option together with \fB-width\fP.

.TP
\fB-top=\fP\fIpixels\fP
.TP
\fB-bottom=\fP\fIpixels\fP
.TP
\fB-height=\fP\fIheight\fP
.TP
\fB-valign=\fP\fIratio\fP
.TP
\fB-mheight=\fP\fIpixels\fP
These options determine the vertical padding.  They are analogous to the
horizontal padding options above.

.TP
\fB-reportonly\fP
  This causes \fBpnmpad\fP to write to Standard Output a description of the
  padding it would have done instead of producing an output image.  See
  
.UR #reportonly
below
.UE
\& for a description of this output and ways
  to use it.
.sp
This option was new in Netpbm 10.89 (December 2019).

.TP
\fB-verbose\fP
This causes verbose messages.



.UN reportonly
.SH REPORT ONLY
.PP
When you specify \fB-reportonly\fP, \fBpnmpad\fP does not produce an
  output image.  Instead, it writes to Standard Output a description of the
  padding it would have done without \fB-reportonly\fP.
.PP
That description is one line of text, containing 6 decimal numbers of
  pixels, separated by spaces:


.IP \(bu
left padding
.IP \(bu
right padding
.IP \(bu
top padding
.IP \(bu
bottom padding
.IP \(bu
output width
.IP \(bu
output height

.PP
Example:
.nf
    
      4 3 0 2 100 100
    

.fi
.PP
One use for this is to make padding which is fancier than the black and
  white that \fBpnmpad\fP can do.
.PP
In the following example, we pad an image with 10 pixels of gray all
  around, without knowing the original image dimensions beforehand.  We do
  this by generating a gray image with \fBpbmmake\fP and then pasting the
  subject image into the middle of it.
.PP
The example uses shell arrays, such as exist in Bash, but not Dash.
  
.nf
    \f(CW
    pad=($(pnmpad -reportonly -left=10 -right=10 -top=10 -bottom=10 input.ppm))
    pbmmake -gray ${pad[4]} ${pad[5]} | \e
      pnmpaste input.ppm ${pad[0]} ${pad[2]} -
    \fP

.fi
    

.UN history
.SH HISTORY
.PP
Before February 2002, \fBpnmpad\fP had a different option syntax
which was less expressive and not like conventional Netpbm programs.
That syntax is still understood by \fBpnmpad\fP for backward
compatibility, but not documented or supported for future use.


.UN seealso
.SH SEE ALSO
.BR "pbmmake" (1)\c
\&,
.BR "pnmpaste" (1)\c
\&,
.BR "pamcut" (1)\c
\&,
.BR "pnmcrop" (1)\c
\&,
.BR "pamcomp" (1)\c
\&,
.BR "pnmmargin" (1)\c
\&,
.BR "pbm" (1)\c
\&


.UN author
.SH AUTHOR
.PP
Copyright (C) 2002 by Martin van Beilen
.PP
Copyright (C) 1990 by Angus Duggan
.PP
Copyright (C) 1989 by Jef Poskanzer.
.PP
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation.  This software is provided "as is"
without express or implied warranty.
.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/pnmpad.html
.PP