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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//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>
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 other than 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 >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 >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="#limitations">LIMITATIONS</A>
<LI><A HREF="#author">AUTHOR</A>
</UL>
</BODY>
</HTML>
|