summary refs log tree commit diff
path: root/jpegtopnm.html
blob: 9262e0330cbd1c97aba840e9e082684c763d16e7 (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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN">
<html><head><title>Jpegtopnm User Manual</title></head>
<body>
<h1>jpegtopnm</h1>
Updated: 13 October 2002
<br>
<a href="#index">Table Of Contents</a>

<h2>NAME</h2>
jpegtopnm - convert JPEG/JFIF file to PPM or PGM image

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

<b>jpegtopnm</b>
[<b>-dct</b> {<b>int</b>|<b>fast</b>|<b>float</b>}]
[<b>-nosmooth</b>]
[<b>-maxmemory</b> <i>N</i>]
[{<b>-adobe</b>|<b>-notadobe</b>}]
[<b>-comments</b>]
[<b>-dumpexif</b>]
[<b>-exif=</b><i>filespec</i>]
[<b>-multiple</b>]
[<b>-repair</b>]
[<b>-verbose</b>]
[<b>-tracelevel</b> <i>N</i>]
[<i>filename</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>jpegtopnm</b> converts JFIF images to PPM or PGM images.

<p>By default, <b>jpegtopnm</b> expects the input stream to contain one
JFIF image and produces one PGM or PPM image as output.  It fails if the
input stream is empty.

<p>But with the <b>-multiple</b> option, <b>jpegtopnm</b> reads JFIF
images sequentially from the input stream and writes one PPM or PGM image
to the output stream for each JFIF input.  If the input stream is empty,
so is the output.

<p>The input stream is the <i>filename</i> you specify or, if you
don't specify <i>filename</i>, Standard Input.  The output stream is
Standard Output.

<p>If a JFIF input image is of the grayscale variety, <b>jpegtopnm</b>
generates a PGM image.  Otherwise, it generates a PPM image.

<p>Before Netpbm 10.11 (October 2002), <b>jpegtopnm</b> did not have
the multiple image stream capability.  From 10.11 through 10.22,
Netpbm always behaved as if you specified <b>-multiple</b>.  Starting
with Netpbm 10.23 (July 2004), Netpbm's default behavior went back to
the pre-10.11 behavior and the new <b>-multiple</b> option selected
the 10.12 behavior.  The reason for the reversion was that there were
discovered in the world files that contain JFIF images followed by
something other than another JFIF image.  The producers of these files
expect them to work with any JFIF interpreter because most JFIF
interpreters just stop reading the file after the first JFIF image.

<p><b>jpegtopnm</b> uses the Independent JPEG Group's JPEG library to
interpret the input file.  See <b><a
href="http://www.ijg.org">http://www.ijg.org</a> </b>
for information on the library.

<p>"JFIF" is the correct name for the image format commonly
known as "JPEG." Strictly speaking, JPEG is a method of
compression.  The image format using JPEG compression that is by far
the most common is JFIF.  There is also a subformat of TIFF that uses
JPEG compression.

<p>EXIF is an image format that is a subformat of JFIF (to wit, a JFIF
file that contains an EXIF header as an APP1 marker).
<b>jpegtopnm</b> handles EXIF.

<p>JFIF files can have either 8 bits per sample or 12 bits per sample.
The 8 bit variety is by far the most common.  There are two versions
of the IJG JPEG library.  One reads only 8 bit files and the other
reads only 12 bit files.  You must link the appropriate one of these
libraries with <b>jpegtopnm</b>.  Ordinarily, this means the library
is in your shared library search path when you run <b>jpegtopnm</b>.

<p><b>jpegtopnm</b> generates output with either one byte or two bytes
per sample depending on whether the JFIF input has either 8 bits or 12
bits per sample.  You can use <b>pamdepth</b> to reduce a
two-byte-per-sample file to a one-byte-per-sample file if you need to.

<p>If the JFIF file uses the CMYK or YCCK color space, the input does
not actually contain enough information to know what color each pixel
is.  To know what color a pixel is, one would have to know the
properties of the inks to which the color space refers.
<b>jpegtopnm</b> interprets the colors using the common transformation
which assumes all the inks are simply subtractive and linear.

<p>See the <a href="jpegtopnm.html"><b>jpegtopnm</b> manual</a>
for information on how images lose quality when you convert to and
from JFIF.

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

<p>
The options are only for advanced users.

<dl compact>
<dt><b>-dct int</b>

<dd>
Use integer DCT method (default).

<dt><b>-dct fast</b>

<dd>
Use fast integer DCT (less accurate).

<dt><b>-dct float</b>

<dd>
Use floating-point DCT method.
The float method is very slightly more accurate than the int method, but is
much slower unless your machine has very fast floating-point hardware.  Also
note that results of the floating-point method may vary slightly across
machines, while the integer methods should give the same results everywhere.
The fast integer method is much less accurate than the other two.

<dt><b>-nosmooth</b>

<dd>
Use a faster, lower-quality upsampling routine.
<dt><b>-maxmemory</b><i> N</i>

<dd>Set limit on the amount of memory <b>jpegtopnm</b> uses in
processing large images.  Value is in thousands of bytes, or millions
of bytes if "M" is suffixed to the number.  For example,
<b>-maxmemory 4m</b> selects 4000000 bytes.  If <b>jpegtopnm</b> needs
more space, it uses temporary files.

<dt><b>-adobe</b>
<dt><b>-notadobe</b>

<dd>
There are two variations on the CMYK (and likewise YCCK) color space that
may be used in the JFIF input.  In the normal one, a zero value for a color
components indicates absence of ink.  In the other, a zero value means the
maximum ink coverage.  The latter is used by Adobe Photoshop when it creates
a bare JFIF output file (but not when it creates JFIF output as part of
Encapsulated Postscript output).  

<p>These options tell <b>jpegtopnm</b> which version of the CMYK or
YCCK color space the image uses.  If you specify neither,
<b>jpegtopnm</b> tries to figure it out on its own.  In the present
version, it doesn't try very hard at all: It just assumes the
Photoshop version, since Photoshop and its emulators seem to be the
main source of CMYK and YCCK images.  But with experience of use,
future versions might be more sophisticated.

<p>If the JFIF image does not indicate that it is CMYK or YCCK, these
options have no effect.

<p>If you don't use the right one of these options, the symptom is
output that looks like a negative.

<dt><b>-dumpexif</b>

<dd>Print the interpreted contents of any Exif header in the input
file to the Standard Error file.  Similar to the program <b>jhead</b>
(not part of the Netpbm package).

<p>This option was added in Netpbm 9.19 (September 2001).
     
<dt><b>-exif=</b><i>filespec</i>

<dd>Extract the contents of the EXIF header from the input image and
write it to the file <i>filespec</i>.  <i>filespec</i>=<b>-</b> means
write it to Standard Output.  When you write the EXIF header to
Standard Output, <b>jpegtopnm</b> does not output the converted image
(which is what normally would go to Standard Output) at all.

<p><b>jpegtopnm</b> writes the contents of the EXIF header
byte-for-byte, starting with the two byte length field (which length
includes those two bytes).

<p>You can use this file as input to <b>pnmtojpeg</b> to insert an
identical EXIF header into a new JFIF image.

<p>If there is no EXIF header, <b>jpegtopnm</b> writes two bytes of
binary zero and nothing else.

<p>An EXIF header takes the form of a JFIF APP1 marker.  Only the
first such marker within the JFIF header counts.

<p>This option was added in Netpbm 9.19 (September 2001).

<dt><b>-multiple</b>

<dd>Read multiple JFIF images sequentially from the input stream.
See <a href="#description">Description section</a> for details.

<p>This option was new in Netpbm 10.23 (July 2004).

<dt><b>-repair</b>

<dd>If the JFIF input is invalid, try to salvage whatever information is
there and produce a valid PNM image as output.

<p>Without this option, some invalid input causes <b>jpegtopnm</b>
to fail, and what output it produces is undefined.  With <b>-repair</b>
such invalid input causes <b>jpegtopnm</b> to succeed instead.

<p>But note that there are some forms of invalid input that always cause
<b>jpegtopnm</b> to fail and others that always cause it to salvage image
information and succeed.

<p>One particular case where <b>-repair</b> makes a difference is the
common case that the file is truncated somewhere after the JFIF
header.  Without <b>-repair</b>, that always causes a failure; with
<b>-repair</b> it always causes success.  Because the image
information is laid out generally top to bottom in the JFIF stream,
the image <b>jpegtopnm</b> produces in this case has the proper image
contents at the top, but the bottom is padded with gray.

<p>This option was new in Netpbm 10.38.0 (March 2007).  Before that,
<b>jpegtopnm</b> always fails in the cases in question.


<dt><b>-comments</b>

<dd>
Print any comments in the input file to the Standard Error file.

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

<dd>
Print details about the conversion to the Standard Error file.

<dt><b>-tracelevel</b><i> n</i>

<dd>Turn on the JPEG library's trace messages to the Standard Error
file.  A higher value of <i>n</i> gets more trace information.
<b>-verbose</b> implies a trace level of at least 1.

</dl>

<h2 id="examples">EXAMPLES</h2>

<p>This example converts the color JFIF file foo.jpg to a PPM file
named foo.ppm:

<pre>
    jpegtopnm foo.jpg &gt;foo.ppm
</pre>

<h2 id="hints">HINTS</h2>

You can use <b>pnmquant</b> to color quantize the result, i.e. to
reduce the number of distinct colors in the image.  In fact, you may
have to if you want to convert the PPM file to certain other formats.
<b>ppmdither</b> Does a more sophisticated quantization.

<p>Use <b>pamscale</b> to change the dimensions of the resulting
image.

<p>Use <b>ppmtopgm </b> to convert a color JFIF file to a grayscale
PGM file.

<p>You can easily use these converters together.  E.g.:

<pre>
    jpegtopnm foo.jpg | ppmtopgm | pamscale .25 &gt;foo.pgm
</pre>

<p><b>-dct fast</b> and/or <b>-nosmooth</b> gain speed at a small
sacrifice in quality.

<p>If you are fortunate enough to have very fast floating point
hardware, <b>-dct float</b> may be even faster than <b>-dct fast</b>.
But on most machines <b>-dct float</b> is slower than <b>-dct int</b>;
in this case it is not worth using, because its theoretical accuracy
advantage is too small to be significant in practice.

<p>Another program, <b>djpeg</b>, is similar.  <b>djpeg</b> is
maintained by the Independent JPEG Group and packaged with the JPEG
library which <b>jpegtopnm</b> uses for all its JPEG work.  Because of
that, you may expect it to exploit more current JPEG features.  Also,
since you have to have the library to run <b>jpegtopnm</b>, but not
vice versa, <b>cjpeg</b> may be more commonly available.

<p>On the other hand, <b>djpeg</b> does not use the NetPBM libraries
to generate its output, as all the NetPBM tools such as
<b>jpegtopnm</b> do.  This means it is less likely to be consistent
with all the other programs that deal with the NetPBM formats.  Also,
the command syntax of <b>jpegtopnm</b> is consistent with that of the
other Netpbm tools, unlike <b>djpeg</b>.

<h2 id="environment">ENVIRONMENT</h2>

<dl compact>
<dt><b>JPEGMEM</b>

<dd>If this environment variable is set, its value is the default
memory limit.  The value is specified as described for the
<b>-maxmemory</b> option.  An explicit <b>-maxmemory </b> option
overrides any <b>JPEGMEM</b>.

</dl>

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

<p>
<b><a href="ppm.html">ppm</a></b>,
<b><a href="pgm.html">pgm</a></b>,
<b><a href="pnmtojpeg.html">pnmtojpeg</a></b>,
<b><a href="pnmquant.html">pnmquant</a></b>,
<b><a href="pamscale.html">pamscale</a></b>,
<b><a href="ppmtopgm.html">ppmtopgm</a></b>,
<b><a href="ppmdither.html">ppmdither</a></b>,
<b><a href="pamdepth.html">pamdepth</a></b>,

<p>
<b>djpeg</b> man page,
<b>cjpeg</b> man page,
<b>jpegtran</b> man page,
<b>rdjpgcom</b> man page,
<b>wrjpgcom</b> man page,
<b>jhead</b> man page

<p>Wallace, Gregory K.  "The JPEG Still Picture Compression
Standard", Communications of the ACM, April 1991 (vol. 34,
no. 4), pp. 30-44.

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

<p><b>jpegtopnm</b> and this manual were derived in large part from
<b>djpeg</b>, by the Independent JPEG Group.  The program is otherwise
by Bryan Henderson on March 19, 2000.

<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="#examples">EXAMPLES</a>
<li><a href="#hints">HINTS</a>
<li><a href="#environment">ENVIRONMENT</a>
<li><a href="#seealso">SEE ALSO</a>
<li><a href="#author">AUTHOR</a>
</ul>
</body>
</html>