.TL
Jpegtopnm User Manual
.SH 1
JPEGTOPNM
.LP
Updated: 13 October 2002
.br
Table Of Contents
.SH 2
NAME
.LP
jpegtopnm - convert JPEG/JFIF file to PPM or PGM image
.SH 2
SYNOPSIS
.LP
\fBjpegtopnm\fR
[\fB-dct\fR {\fBint\fR|\fBfast\fR|\fBfloat\fR}]
[\fB-nosmooth\fR]
[\fB-maxmemory\fR \fIN\fR]
[{\fB-adobe\fR|\fB-notadobe\fR}]
[\fB-comments\fR]
[\fB-dumpexif\fR]
[\fB-exif=\fR\fIfilespec\fR]
[\fB-multiple\fR]
[\fB-verbose\fR]
[\fB-tracelevel\fR \fIN\fR]
[\fIfilename\fR]
.LP
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.
.SH 2
DESCRIPTION
.LP
.LP
This program is part of Netpbm.
.LP
\fBjpegtopnm\fR converts JFIF images to PPM or PGM images.
.LP
By default, \fBjpegtopnm\fR 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.
.LP
But with the \fB-multiple\fR option, \fBjpegtopnm\fR 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.
.LP
The input stream is the \fIfilename\fR you specify or, if you
don't specify \fIfilename\fR, Standard Input. The output stream is
Standard Output.
.LP
If a JFIF input image is of the grayscale variety, \fBjpegtopnm\fR
generates a PGM image. Otherwise, it generates a PPM image.
.LP
Before Netpbm 10.11 (October 2002), \fBjpegtopnm\fR did not have
the multiple image stream capability. From 10.11 through 10.22,
Netpbm always behaved as if you specified \fB-multiple\fR. Starting
with Netpbm 10.23 (July 2004), Netpbm's default behavior went back to
the pre-10.11 behavior and the new \fB-multiple\fR 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.
.LP
\fBjpegtopnm\fR uses the Independent JPEG Group's JPEG library to
interpret the input file. See \fBhttp://www.ijg.org \fR
for information on the library.
.LP
"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.
.LP
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).
\fBjpegtopnm\fR handles EXIF.
.LP
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 \fBjpegtopnm\fR. Ordinarily, this means the library
is in your shared library search path when you run \fBjpegtopnm\fR.
.LP
\fBjpegtopnm\fR 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 \fBpamdepth\fR to reduce a
two-byte-per-sample file to a one-byte-per-sample file if you need to.
.LP
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.
\fBjpegtopnm\fR interprets the colors using the common transformation
which assumes all the inks are simply subtractive and linear.
.LP
See the \fBjpegtopnm\fR manual
for information on how images lose quality when you convert to and
from JFIF.
.SH 2
OPTIONS
.LP
The options are only for advanced users:
.RS
.IP "\fB-dct int\fR"
Use integer DCT method (default).
.IP "\fB-dct fast\fR"
Use fast integer DCT (less accurate).
.IP "\fB-dct float\fR"
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.
.IP "\fB-nosmooth\fR"
Use a faster, lower-quality upsampling routine.
.IP "\fB-maxmemory\fR\fI N\fR"
Set limit on the amount of memory \fBjpegtopnm\fR uses in
processing large images. Value is in thousands of bytes, or millions
of bytes if "M" is suffixed to the number. For example,
\fB-maxmemory 4m\fR selects 4000000 bytes. If \fBjpegtopnm\fR needs
more space, it uses temporary files.
.IP "\fB-adobe\fR"
.IP "\fB-notadobe\fR"
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).
.LP
These options tell \fBjpegtopnm\fR which version of the CMYK or
YCCK color space the image uses. If you specify neither,
\fBjpegtopnm\fR 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.
.LP
If the JFIF image does not indicate that it is CMYK or YCCK, these
options have no effect.
.LP
If you don't use the right one of these options, the symptom is
output that looks like a negative.
.IP "\fB-dumpexif\fR"
Print the interpreted contents of any Exif header in the input
file to the Standard Error file. Similar to the program \fBjhead\fR
(not part of the Netpbm package).
.LP
This option was added in Netpbm 9.19 (September 2001).
.IP "\fB-exif=\fR\fIfilespec\fR"
Extract the contents of the EXIF header from the input image and
write it to the file \fIfilespec\fR. \fIfilespec\fR=\fB-\fR means
write it to Standard Output. When you write the EXIF header to
Standard Output, \fBjpegtopnm\fR does not output the converted image
(which is what normally would go to Standard Output) at all.
.LP
\fBjpegtopnm\fR writes the contents of the EXIF header
byte-for-byte, starting with the two byte length field (which length
includes those two bytes).
.LP
You can use this file as input to \fBpnmtojpeg\fR to insert an
identical EXIF header into a new JFIF image.
.LP
If there is no EXIF header, \fBjpegtopnm\fR writes two bytes of
binary zero and nothing else.
.LP
An EXIF header takes the form of a JFIF APP1 marker. Only the
first such marker within the JFIF header counts.
.LP
This option was added in Netpbm 9.19 (September 2001).
.IP "\fB-multiple\fR"
Read multiple JFIF images sequentially from the input stream.
See Description section for details.
.LP
This option was new in Netpbm 10.23 (July 2004).
.IP "\fB-comments\fR"
Print any comments in the input file to the Standard Error file.
.IP "\fB-verbose\fR"
Print details about the conversion to the Standard Error file.
.IP "\fB-tracelevel\fR\fI n\fR"
Turn on the JPEG library's trace messages to the Standard Error
file. A higher value of \fIn\fR gets more trace information.
\fB-verbose\fR implies a trace level of at least 1.
.RE
.SH 2
EXAMPLES
.LP
.LP
This example converts the color JFIF file foo.jpg to a PPM file
named foo.ppm:
.DS L
jpegtopnm foo.jpg >foo.ppm
.DE
.SH 2
HINTS
.LP
You can use \fBpnmquant\fR 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.
\fBppmdither\fR Does a more sophisticated quantization.
.LP
Use \fBpamscale\fR to change the dimensions of the resulting
image.
.LP
Use \fBppmtopgm \fR to convert a color JFIF file to a grayscale
PGM file.
.LP
You can easily use these converters together. E.g.:
.DS L
jpegtopnm foo.jpg | ppmtopgm | pamscale .25 >foo.pgm
.DE
.LP
\fB-dct fast\fR and/or \fB-nosmooth\fR gain speed at a small
sacrifice in quality.
.LP
If you are fortunate enough to have very fast floating point
hardware, \fB-dct float\fR may be even faster than \fB-dct fast\fR.
But on most machines \fB-dct float\fR is slower than \fB-dct int\fR;
in this case it is not worth using, because its theoretical accuracy
advantage is too small to be significant in practice.
.LP
Another program, \fBdjpeg\fR, is similar. \fBdjpeg\fR is
maintained by the Independent JPEG Group and packaged with the JPEG
library which \fBjpegtopnm\fR 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 \fBjpegtopnm\fR, but not
vice versa, \fBcjpeg\fR may be more commonly available.
.LP
On the other hand, \fBdjpeg\fR does not use the NetPBM libraries
to generate its output, as all the NetPBM tools such as
\fBjpegtopnm\fR 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 \fBjpegtopnm\fR is consistent with that of the
other Netpbm tools, unlike \fBdjpeg\fR.
.SH 2
ENVIRONMENT
.LP
.RS
.IP "\fBJPEGMEM\fR"
If this environment variable is set, its value is the default
memory limit. The value is specified as described for the
\fB-maxmemory\fR option. An explicit \fB-maxmemory \fR option
overrides any \fBJPEGMEM\fR.
.RE
.SH 2
SEE ALSO
.LP
.LP
\fBppm\fR,
\fBpgm\fR,
\fBpnmtojpeg\fR,
\fBpnmquant\fR,
\fBpamscale\fR,
\fBppmtopgm\fR,
\fBppmdither\fR,
\fBpamdepth\fR,
.LP
\fBdjpeg\fR man page,
\fBcjpeg\fR man page,
\fBjpegtran\fR man page,
\fBrdjpgcom\fR man page,
\fBwrjpgcom\fR man page,
\fBjhead\fR man page
.LP
Wallace, Gregory K. "The JPEG Still Picture Compression
Standard", Communications of the ACM, April 1991 (vol. 34,
no. 4), pp. 30-44.
.SH 2
LIMITATIONS
.LP
.LP
Arithmetic coding is not offered for legal reasons. The program
could be much faster.
.SH 2
AUTHOR
.LP
.LP
\fBjpegtopnm\fR and this manual were derived in large part from
\fBdjpeg\fR, by the Independent JPEG Group. The program is otherwise
by Bryan Henderson on March 19, 2000.
.br
\l'5i'
.SH 2
Table Of Contents
.LP
.IP \(bu
NAME
.IP \(bu
SYNOPSIS
.IP \(bu
DESCRIPTION
.IP \(bu
OPTIONS
.IP \(bu
EXAMPLES
.IP \(bu
HINTS
.IP \(bu
ENVIRONMENT
.IP \(bu
SEE ALSO
.IP \(bu
LIMITATIONS
.IP \(bu
AUTHOR
.LP
|