JPEGTOPNM(1)
π Jpegtopnm User Manual(1) π
okay bestie, you asked for the Jpegtopnm User Manual(1) and I am delivering. grab a strawberry drink π, because this is the whole vibe: jpegtopnm turns your JPEG/JFIF files into PPM or PGM, and it has opinions. no cap.
β¨ NAME β¨
jpegtopnm - convert JPEG/JFIF file to PPM or PGM image
πΈ SYNOPSIS πΈ
jpegtopnm [-dct {int|fast|float}] [-nosmooth] [-maxmemory N]
[{-adobe|-notadobe}] [-comments] [-dumpexif] [-exif=filespec]
[-multiple] [-repair] [-verbose] [-tracelevel N] [-traceexif] [filename]
Also, quick note bestie: "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." remember that, it's giving flexible π
π¦ DESCRIPTION π¦
This program is part of Netpbm(1). slay.
jpegtopnm converts JFIF images to PPM or PGM images.
By default, jpegtopnm 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. not it π
But with the -multiple option, jpegtopnm 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. balanced β¨
The input stream is the filename you specify or, if you don't specify filename, Standard Input. The output stream is Standard Output.
If a JFIF input image is of the grayscale variety, jpegtopnm generates a PGM image. Otherwise, it generates a PPM image.
Before Netpbm 10.11 (October 2002), jpegtopnm did not have the multiple image stream capability. From 10.11 through 10.22, Netpbm always behaved as if you specified -multiple. Starting with Netpbm 10.23 (July 2004), Netpbm's default behavior went back to the pre-10.11 behavior and the new -multiple 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. history lesson, periodt.
jpegtopnm uses the Independent JPEG Group's JPEG library to interpret the input file. See http://www.ijg.org for information on the library. iykyk.
"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. bougie π
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. link it right or it's giving broken.
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 pamdepth 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. math is mathing.
See the jpegtopnm manual(1) for information on how images lose quality when you convert to and from JFIF.
β¨ OPTIONS β¨
In addition to the options common to all programs based on libnetpbm (most notably -quiet, see Common Options), jpegtopnm recognizes the following command line options:
The options are only for advanced users. don't come for me, I'm just the messenger π«Ά
-dct intβ Use integer DCT method (default). the standard-dct fastβ Use fast integer DCT (less accurate). zoom zoom, kinda blurry-dct floatβ 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.-nosmoothβ Use a faster, lower-quality upsampling routine.-maxmemory Nβ Set limit on the amount of memoryjpegtopnmuses in processing large images. Value is in thousands of bytes, or millions of bytes ifMis suffixed to the number. For example,-maxmemory 4mselects4000000bytes. Ifjpegtopnmneeds more space, it uses temporary files.-adobe,-notadobeβ 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).
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. jumpscare π
-dumpexifβ Print the interpreted contents of any Exif header in the input file to the Standard Error file. Similar to the programjhead(not part of the Netpbm package).
This option was added in Netpbm 9.19 (September 2001).
-exif=filespecβ Extract the contents of the EXIF header from the input image and write it to the filefilespec.filespec=-means write it to Standard Output. When you write the EXIF header to Standard Output,jpegtopnmdoes not output the converted image (which is what normally would go to Standard Output) at all.
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 pnmtojpeg 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).
-multipleβ Read multiple JFIF images sequentially from the input stream. See Description section for details.
This option was new in Netpbm 10.23 (July 2004).
-repairβ If the JFIF input is invalid, try to salvage whatever information is there and produce a valid PNM image as output.
Without this option, some invalid input causes jpegtopnm to fail, and what output it produces is undefined. With -repair such invalid input causes jpegtopnm to succeed instead.
But note that there are some forms of invalid input that always cause jpegtopnm to fail and others that always cause it to salvage image information and succeed.
One particular case where -repair makes a difference is the common case that the file is truncated somewhere after the JFIF header. Without -repair, that always causes a failure; with -repair it always causes success. Because the image information is laid out generally top to bottom in the JFIF stream, the image jpegtopnm produces in this case has the proper image contents at the top, but the bottom is padded with gray.
This option was new in Netpbm 10.38.0 (March 2007). Before that, jpegtopnm always fails in the cases in question.
-commentsβ Print any comments in the input file to the Standard Error file.-verboseβ Print details about the conversion to the Standard Error file.-tracelevel nβ Turn on the JPEG library's trace messages to the Standard Error file. A higher value ofngets more trace information.-verboseimplies a trace level of at least1.-traceexifβ Print trace information about the processing of EXIF header information.
This option was new in Netpbm 11.02 (March 2023).
π EXAMPLES π
This example converts the color JFIF file foo.jpg to a PPM file named foo.ppm:
jpegtopnm foo.jpg >foo.ppm
π‘ HINTS π‘
Okay bestie, so you got your PPM out of jpegtopnm β now what? Here's the tea π΅
- Wanna shrink the color palette, like, reduce how many distinct colors live in your image? That's a job for
pnmquant, and yes it's the color-quantize queen. Fun fact: you might have to run it if you wanna take that PPM file to certain other formats. It's giving mandatory. ppmditherdoes a fancier, more sophisticated quantization if you're feeling extra β¨- Wanna change the dimensions of your resulting image?
pamscaleis your girl. - Trying to turn a color JFIF file into a grayscale PGM file?
ppmtopgmsaid "let me handle that."
And the way these converters just snap together?? Iconic. Watch:
jpegtopnm foo.jpg | ppmtopgm | pamscale .25 >foo.pgm
See how they eat each other's output? Chef's kiss π
Now, speed hacks: -dct fast and/or -nosmooth will gain you speed at a small sacrifice in quality. That's the trade, no cap.
If you're fortunate enough (manifesting π¦) to have very fast floating point hardware, -dct float may be even faster than -dct fast. But bestie, listen β on most machines -dct float is slower than -dct int, and in that case it is not worth using, because its theoretical accuracy advantage is too small to be significant in practice. Don't fall for the hype on mid hardware π
So there's this other program, djpeg, and it's similar. djpeg is maintained by the Independent JPEG Group and packaged with the JPEG library β which, btw, 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. Situationship dynamics, honestly.
On the other hand (there's always another hand π), djpeg does not use the NetPBM libraries to generate its output, the way all the NetPBM tools such as jpegtopnm do. Which means it's 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. So there's your vibe check β pick your fighter π
πΈ ENVIRONMENT πΈ
JPEGMEMβ if this environment variable is set, its value becomes the default memory limit. The value is specified the same way as described for the-maxmemoryoption. And heads up: an explicit-maxmemoryoption overrides anyJPEGMEM. Explicit beats ambient, periodt.
π SEE ALSO π
ppm(1),pgm(1),pnmtojpeg(1),pnmquant(1),pamscale(1),ppmtopgm(1),ppmdither(1),pamdepth(1),djpegman page,cjpegman page,jpegtranman page,rdjpgcomman page,wrjpgcomman page,jheadman page- Wallace, Gregory K. "The JPEG Still Picture Compression Standard", Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
π AUTHOR π
jpegtopnm and this manual were derived in large part from djpeg, by the Independent JPEG Group. The program is otherwise by Bryan Henderson on March 19, 2000. Shoutout to the ancestors of this codebase π«Ά
π DOCUMENT SOURCE π
This manual page was generated by the Netpbm tool makeman from HTML source. The master documentation is at
http://netpbm.sourceforge.net/doc/jpegtopnm.html
And that's the whole page, bestie!! π This was netpbm documentation, dated 20 March 2023, the Jpegtopnm User Manual(1). Go forth and convert your JPEGs, you absolute main character πβ¨π¦
π¦ where this page comes from
- debian trixie: netpbm 2:11.10.02-1 Β· MIT
- ubuntu noble: netpbm 2:11.05.02-1.1build1 Β· MIT
- ubuntu resolute: netpbm 2:11.10.02-1build1 Β· MIT
- ubuntu stonking: netpbm 2:11.13.03+ds-2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms