Minimum unique abbreviation of option is acceptable. You may use double hypens 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.
jpegtopnm converts JFIF images to PPM or PGM images. jpegtopnm reads JFIF images sequentially from filename or, if you don't specify filename, from Standard Input. For each image, it writes a PGM or PPM image sequentially to Standard Output.
If a JFIF input image is of the grayscale variety, jpegtopnm generates a PGM image. Otherwise, it generates a PPM image.
If the input is an empty file, so is the output.
Before Netpbm 10.11 (October 2002), jpegtopnm read exactly one image. Images after the first were ignored and empty input caused the program to fail. jpegtopnm uses the Independent JPEG Group's JPEG library to interpret the input file. See http://www.ijg.org for information on the library.
"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.
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). jpegtopnm handles EXIF.
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 jpegtopnm. Ordinarily, this means the library is in your shared library search path when you run jpegtopnm.
jpegtopnm 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 pnmdepth to reduce a two-byte-per-sample file to a one-byte-per-sample file if you need to.
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. jpegtopnm interprets the colors using the common transformation which assumes all the inks are simply subtractive and linear.
These options tell jpegtopnm which version of the CMYK or YCCK color space the image uses. If you specify neither, jpegtopnm 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.
If the JFIF image does not indicate that it is CMYK or YCCK, these options have no effect.
If you don't use the right one of these options, the symptom is output that looks like a negative.
This option was added in Netpbm 9.19 (September 2001).
jpegtopnm writes the contents of the EXIF header byte-for-byte, starting with the two byte length field (which length includes those two bytes).
You can use this file as input to ppmtojpeg to insert an identical EXIF header into a new JFIF image.
If there is no EXIF header, jpegtopnm writes two bytes of binary zero and nothing else.
An EXIF header takes the form of a JFIF APP1 marker. Only the first such marker within the JFIF header counts.
This option was added in Netpbm 9.19 (September 2001).
This example converts the color JFIF file foo.jpg to a PPM file named foo.ppm:
Use pnmscale to change the dimensions of the resulting image.
Use ppmtopgm to convert a color JFIF file to a grayscale PGM file.
You can easily use these converters together. E.g.:
-dct fast and/or -nosmooth gain speed at a small sacrifice in quality.
If you are fortunate enough to have very fast floating point hardware, -dct float may be even faster than -dct fast. But on most machines -dct float is slower than -dct int; in this case it is not worth using, because its theoretical accuracy advantage is too small to be significant in practice.
Another program, djpeg, is similar. djpeg is maintained by the Independent JPEG Group and packaged with the JPEG library which jpegtopnm 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 jpegtopnm, but not vice versa, cjpeg may be more commonly available.
On the other hand, djpeg does not use the NetPBM libraries to generate its output, as all the NetPBM tools such as jpegtopnm 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 jpegtopnm is consistent with that of the other Netpbm tools, unlike djpeg.
The program could be much faster.