summary refs log tree commit diff
path: root/pamfix.html
blob: f4021fc77b24535914fdd2579400e59c0e134a7c (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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN">
<html><head><title>Pamfix User Manual</title></head>
<body>
<h1>pamfix</h1>
Updated: 06 March 2014
<br>
<a href="#index">Table Of Contents</a>

<h2>NAME</h2>

pamfix - repair a Netpbm image with various corruptions

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

<b>pamfix</b>

[<b>-truncate</b>]
[<b>-changemaxval</b>]
[<b>-clip</b>]
[<b>-verbose</b>]

[<i>netpbmfile</i>]

<p>Minimum unique abbreviation of option is 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>pamfix</b> reads a stream that is mostly a Netpbm image but may have
certain types of corruptions and produces a valid Netpbm image that preserves
much of the information in the original.

In particular, Netpbm salvages streams that are truncated and that contain
illegally large sample values.

<p><b>pamfix</b> looks at only on the first image in a multi-image stream.


<h3 id="truncatedstream">Truncated Stream</h3>

<p>This is a stream that is missing the last part.  Netpbm corrects this
by creating an output image that simply has fewer rows.

<p>You select this kind of repair with a <b>-truncate</b> option.

<p>The header of a Netpbm image implies how large the image must
be (how many bytes the file must contain).  If the file is actually
smaller than that, a Netpbm program that tries to read the image
fails, with an error message telling you that it couldn't read the
whole file.  The data in the file is arranged in row order, from
top to bottom, and the most common reason for the file being smaller
than its header says it should be is because the bottommost rows are
simply missing.  So <b>pamfix</b> assumes that is the case
and generates a new image with just the rows that are readable.
(technically, that means the output's header indicates a smaller
number of rows and omits any partial last row).

<p>The most common way for a Netpbm file to be small is that something
interrupted the program that generated it before it was finished writing
the file.  For example, the program ran out of its own input or
encountered a bug or ran out of space in which to write the output.

<p>Another problem <b>pamfix</b> deals with is where the file isn't
actually too small, but because of a system error, a byte in the middle of
it cannot be read (think of a disk storage failure).  <b>pamfix</b>
reads the input sequentially until it can't read any further, for any
reason.  So it treats such an image as a truncated one, ignoring all
data after the unreadable byte.

<p>But be aware that an image file is sometimes too small because of a
bug in the program that generated it, and in that case it is not
simply a matter of the bottom of the image missing, so
<b>pamfix</b> simply creates a valid Netpbm image containing a
garbage picture.

<p>If you want to test an image file to see if it is corrupted by being
too small, use <b>pamfile --allimages</b> .  It fails with an error
message if the file is too small.

<p>If you want to cut the bottom off a valid Netpbm image, use
<b>pamcut</b>.


<h3 id="excessivesample">Excessive Sample Value</h3>

<p>This is a stream that contains a purported sample value that is higher than
the maxval of the image.

<p>The header of a Netpbm image tells the maxval of the image, which is a
value that gives meaning to all the sample values in the raster.  The
sample values represent a fraction of the maxval, so a sample value that is
greater than the maxval makes no sense.

<p>A regular Netpbm program fails if you give it input that contains a value
larger than the maxval where a sample value belongs.

<p><b>pamfix</b> has three ways of salvaging such a stream:

<ul>
<li>Clip to the maxval.  Request this with <b>-clip</b>.
<li>Raise the maxval, thus lowering the fraction represented by every sample
in the image.  Request this with <b>-changemaxval</b>.
<li>Truncate the image at the first invalid sample value.  Request this with
<b>-truncate</b> and neither <b>-clip</b> nor <b>-changemaxval</b>.
</ul>

<p>You cannot specify both <b>-clip</b> and <b>-changemaxval</b>.


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

<dl compact>
<dt><b>-truncate</b>

<dd>Create a truncated output image from all the valid input rows that
could be read.

<dt><b>-changemaxval</b>

<dd>Raise the maxval to cope with pixel values that exceed the maxval
stated in the header of the input file.

<dt><b>-clip</b>

<dd>Change all pixel values that exceed the maxval stated in the header
of the input file.

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

<dd>Report details of the transportation to standard error.

</dl>

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

<a href="pnm.html">pnm</a>,
<a href="pam.html">pam</a>,
<a href="pamcut.html">pamcut</a>,
<a href="pamfile.html">pamfile</a>,
<a href="pamvalidate.html">pamvalidate</a>

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

<p><b>pamfix</b> was new in Netpbm 10.66 (March 2014).  But it grew out of
<b>pamfixtrunc</b>, which was new in Netpbm 10.38 (March 2007) and did only
the truncated image repair (and for invalid sample values would simply pass
them through to its output, generating an invalid Netpbm image).

<hr>
<h2 id="index">Table Of Contents</h2>
<ul>
<li><a href="#synopsis">SYNOPSIS</a>
<li><a href="#description">DESCRIPTION</a>
  <ul> 
  <li><a href="#truncatedstream">Truncated Stream</a>
  <li><a href="#excessivesample">Excessive Sample Value</a>
  </ul>
<li><a href="#options">OPTIONS</a>
<li><a href="#seealso">SEE ALSO</a>
<li><a href="#history">HISTORY</a>
</ul>
</body>
</html>