summary refs log tree commit diff
path: root/pamflip.html
blob: f0e780c404697e671010fd2bba289fb03ade1176 (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
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN">
<html><head><title>Pamflip User Manual</title></head>
<body>
<h1>pamflip</h1>
Updated: 20 January 2008
<br>
<a href="#index">Table Of Contents</a>

<h2>NAME</h2>

pamflip - flip or rotate a PAM or PNM image

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

<b>pamflip</b>
{
<b>-leftright</b> | <b>-lr</b> |
<b>-topbottom</b> | <b>-tb</b> |
<b>-transpose</b> | <b>-xy</b> |
<b>-rotate90</b> | <b>-r90</b> | <b>-cw</b> |
<b>-rotate270</b> | <b>-r270</b> | <b>-ccw</b> |
<b>-rotate180</b> | <b>-r180</b>
<b>-null</b> |
<b>-xform=</b><i>xform1</i><b>,</b><i>xform2</i>...
}
[<b>-memsize=</b><i>mebibytes</i>]
[<b>-pagesize=</b><i>bytes</i>]
[<i>pamfile</i>]

<p>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.


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

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

<p><b>pamflip</b> flips a PAM or PNM image top for bottom or left for right,
or transposes it horizontal for vertical, or rotates it 1, 2, or 3 quarter
turns.

<p>To rotate at other angles, use <b>pnmrotate</b>.  It is much slower,
though.

<p>The input image is <i>pamfile</i>, or Standard Input if <i>pamfile</i>
is not specified.

<p>To flip/rotate a JFIF (JPEG) image losslessly, use <b>jpegtran</b>.
<b>jpegtran</b> is part of the Independent Jpeg Group's compression
library package, not part of Netpbm.  The normal Netpbm way to flip a
JFIF file would be to convert it to PNM, use <b>pamflip</b>, and convert
back to JFIF.  But since JPEG compression is lossy, the resulting image
would have less quality than the original.  <b>jpegtran</b>, on the other
hand, can do this particular transformation directly on the compressed
data without loss.


<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>pamflip</b> recognizes the following
command line options:

<h3 id="transformation">Specifying the Transformation</h3>

<p>You must supply exactly one of the following options:

<p><b>pamflip</b>'s predecessor (before Netpbm 10.7 - August 2002)
<b>pnmflip</b> did not have the <b>-xform</b> option and instead
allowed you to specify any number of the other options, including
zero.  It applied all the indicated transformations, in the order
given, just like with <b>pamflip</b>'s <b>-xform</b> option.  (Reason
for the change: this kind of interpretation of options is inconsistent
with the rest of Netpbm and most of the Unix world, and thus hard to
understand and to implement).

<dl>
<dt><b>-leftright</b>
<dt><b>-lr</b>
<dd>Flip left for right.

<dt><b>-topbottom</b>
<dt><b>-tb</b>
<dd>Flip top for bottom.

<dt><b>-transpose</b>
<dt><b>-xy</b>
<dd>Transpose horizontal for vertical.  I.e. make the pixel at (x,y) be
at (y,x).

<dt><b>-rotate90</b>
<dt><b>-r90</b>
<dt><b>-ccw</b>
<dd>Rotate counterclockwise 90 degrees.

<dt><b>-rotate180</b>
<dt><b>-r180</b>
<dd>Rotate 180 degrees.

<dt><b>-rotate270</b>
<dt><b>-r270</b>
<dt><b>-cw</b>
<dd>Rotate counterclockwise 270 degrees (clockwise 90 degrees)

<dt><b>-null</b> 
<dd>No change.  (The purpose of this option is the
convenience of programs that invoke <b>pamflip</b> after computing the
kind of transformation desired, including none at all).

<p>This option was new in Netpbm 10.13 (December 2002).
     
<dt><b>-xform=</b><i>xform1</i><b>,</b><i>xform2</i>...

<dd>Apply all the transforms listed, in order.  The valid values for
the transforms are as follows and have the same meanings as the
identically named options above.
<ul>
<li>leftright
<li>topbottom
<li>transpose
</ul>

<p>This option was new in Netpbm 10.13 (December 2002).

</dl>

<h3 id="memory">Memory Management</h3>

<p>The following options help <b>pamflip</b> use memory efficiently.
Some flipping operations on very large images can cause <b>pamflip</b>
to have a very large working set, which means if you don't have enough
real memory, the program can page thrash, which means it takes a
ridiculous amount time to run.  If your entire image fits in real
memory, you don't have a problem.  If you're just flipping top for
bottom or left for right, you don't have a problem.  Otherwise, pay
attention.  If you're interested in the details of the thrashing
problem and how <b>pamflip</b> approaches it, you're invited to read
a complete explanation in comments in the source code.

<dl>
<dt><b>-memsize=</b><i>mebibytes</i>

<dd><i>mebibytes</i> is the size in mebibytes (aka megabytes) of
memory available for <b>pamflip</b>.  It is the lesser of the amount
of real or virtual memory available.

<b>pamflip</b> does nothing special to allocate real memory or control
it's allocation -- it gets whatever it gets just by referencing
virtual memory normally.  The real memory figure in question is the
maximum amount that <b>pamflip</b> can be expected to end up with by
doing that.  This is just about impossible for you to know, of course,
but you can estimate.  The total real memory in your system should be
a major factor in your estimate.

<p>If <b>pamflip</b> cannot fit the entire image in the amount of
memory you specify, it does the transformation in chunks, using temporary
files for intermediate results.

<p>In strict horizontal transformations (left for right) or the null
transformation, <b>pamflip</b> never keeps more than one row in memory, so the
memory size is irrelevant and <b>pamflip</b> doesn't use temporary files.

<p>In strict vertical transformations (top for bottom), even when you
allow <b>pamflip</b> enough memory to keep the entire image in virtual memory,
it accesses it in a single pass, which does not cause any thrashing; the
chunks in temporary files thus don't help.
  
<p>The real memory is important when you do a column for row type of
transformation (e.g. <b>-rotate90</b>).  In that case, even if
<b>pamflip</b> can fit the entire image in virtual memory at once, if
it does not also fit in real memory, the program will thrash like
crazy because of the order in which <b>pamflip</b> accesses the
pixels, and that means it will take a ridiculously long time to run.
A proper <b>-memsize</b> drastically reduces the paging.

<p>If you specify <b>-memsize</b> too large, <b>pamflip</b> may
attempt to get more virtual memory than the system allows it and fail.
If it can get the virtual memory, but <b>-memsize</b> is larger than
the amount of real memory the system allows it and the transformation
is row for column, it will page thrash and run very slowly.  A value
even slightly too high is the same as infinity.

<p>If you specify <b>-memsize</b> too small, the program will run
slightly more slowly because of extra overhead in manipulating temporary
files.  Also, if your environment isn't set up to make temporary files
possible, <b>pamflip</b> will fail.

<p>Doing the entire transformation "in memory" doesn't speed
things up as much as you might think, because even with the temporary
files, the data is just as likely to be in memory.  Virtual memory
gets paged to disk and disk files get cached in memory.  In fact, the
pixels fit much more compactly into memory when stored in a temporary
file than when stored "in memory" because <b>pamflip</b>
uses a more efficient format.  So you're likely to have <em>less</em>
disk I/O when you allow <b>pamflip</b> less memory.

<p>If you do not specify <b>-memsize</b>, <b>pamflip</b> assumes
infinity.

<p>This option did not exist before Netpbm 10.7 (August 2002).

<p>Before Netpbm 10.42 (March 2008), this option applied only to real
memory.  <b>pamflip</b> would always keep the entire image in virtual
memory and if it could not get enough virtual memory, it failed.
<b>pamflip</b> accessed the pixels in an order designed to keep real
memory use within the specified amount.
     
<dt><b>-pagesize=</b><i>bytes</i>
<dd><i>bytes</i> is the size in bytes of a paging unit -- the amount of
memory that gets paged in or out as an indivisible unit -- in your system.
The default is 4KiB.

<p>This option has no effect.

<p>Before Netpbm 10.42 (March 2008), <b>pamflip</b> used it to control its
use of real memory.

<p>This option did not exist before Netpbm 10.7 (August 2002).

</dl>

<h3 id="misc">Miscellaneous</h3>

<dl>
<dt><b>-verbose</b>
<dd>This option causes <b>pamflip</b> to issue messages to Standard Error
about its progress.
</dl>

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

<a href="pnmrotate.html">pnmrotate</a>, 
<a href="pnm.html">pnm</a>,
<a href="pam.html">pam</a>,
<b>jpegtran</b> manual

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

<p><b>pamflip</b> replaced <b>pnmflip</b> in Netpbm 10.13 (December 2002).
<b>pamflip</b> is backward compatible, but also works on PAM images.


<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>
  <ul>
  <li><a href="#transformation">Specifying the Transformation</a>
  <li><a href="#memory">Memory Management</a>
  <li><a href="#misc">Miscellaneous</a>
  </ul>
<li><a href="#seealso">SEE ALSO</a>
<li><a href="#history">HISTORY</a>
<li><a href="#author">AUTHOR</a>
</ul>
</body>
</html>