jpegtran translates JPEG files from one variant of JPEG to another, for example from baseline JPEG to progressive JPEG. The transformation is lossless: no image degradation occurs, which would not be true if you used djpeg followed by cjpeg. However, you cannot alter the image quality, because that would not be a lossless operation. jpegtran reads the named JPEG/JFIF file, or the standard input if no file is named, and produces a JPEG/JFIF file on the standard output.
All switch names may be abbreviated; for example, -optimize may be written -opt or -o. Upper and lower case are equivalent. British spellings are also accepted (e.g., -optimise), though for brevity these are not mentioned below.
The basic switches are:
The -progressive switch creates a "progressive JPEG" file. In this type of JPEG file, the data is stored in multiple scans of increasing quality. If the file is being transmitted over a slow communications link, the decoder can use the first scan to display a low-quality image very quickly, and can then improve the display with each subsequent scan. The final image is exactly equivalent to a standard JPEG file of the same quality setting, and the total file size is about the same --- often a little smaller. Caution: progressive JPEG is not yet widely implemented, so many decoders will be unable to view a progressive JPEG file at all.
Switches for advanced users:
The -restart option inserts extra markers that allow a JPEG decoder to resynchronize after a transmission error. Without restart markers, any damage to a compressed file will usually ruin the image from the point of the error to the end of the image; with restart markers, the damage is usually confined to the portion of the image up to the next restart marker. Of course, the restart markers occupy extra space. We recommend -restart 1 for images that will be transmitted across unreliable networks such as Usenet.
Switches for wizards:
The "wizard" switches are intended for experimentation with JPEG. If you don't know what you are doing, don't use them. These switches are documented further in the file wizard.doc.
This example converts a baseline JPEG file to progressive form:
Still not as fast as we'd like.