|
NAMEjpegtran - lossless transformation of JPEG filesSYNOPSISjpegtran [ options ] [ filename ]DESCRIPTIONjpegtran performs various useful transformations of JPEG files. It can translate the coded representation from one variant of JPEG to another, for example from baseline JPEG to progressive JPEG or vice versa. It can also perform some rearrangements of the image data, for example turning an image from landscape to portrait format by rotation.For EXIF files and JPEG files containing Exif data, you may prefer to use exiftran instead. jpegtran works by rearranging the compressed data (DCT coefficients), without ever fully decoding the image. Therefore, its transformations are lossless: there is no image degradation at all, which would not be true if you used djpeg followed by cjpeg to accomplish the same conversion. But by the same token, jpegtran cannot perform lossy operations such as changing the image quality. However, while the image data is losslessly transformed, metadata can be removed. See the -copy option for specifics. 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. OPTIONSAll 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.To specify the coded JPEG representation used in the output file, jpegtran accepts a subset of the switches recognized by cjpeg:
See cjpeg(1) for more details about these switches. If you specify none of these switches, you get a plain baseline-JPEG output file. The quality setting and so forth are determined by the input file. The image can be losslessly transformed by giving one of these switches:
The transpose transformation has no restrictions regarding image dimensions. The other transformations operate rather oddly if the image dimensions are not a multiple of the iMCU size (usually 8 or 16 pixels), because they can only transform complete blocks of DCT coefficient data in the desired way. jpegtran's default behavior when transforming an odd-size image is designed to preserve exact reversibility and mathematical consistency of the transformation set. As stated, transpose is able to flip the entire image area. Horizontal mirroring leaves any partial iMCU column at the right edge untouched, but is able to flip all rows of the image. Similarly, vertical mirroring leaves any partial iMCU row at the bottom edge untouched, but is able to flip all columns. The other transforms can be built up as sequences of transpose and flip operations; for consistency, their actions on edge pixels are defined to be the same as the end result of the corresponding transpose-and-flip sequence. For practical use, you may prefer to discard any untransformable edge pixels rather than having a strange-looking strip along the right and/or bottom edges of a transformed image. To do this, add the -trim switch:
This version of jpegtran also offers a lossless crop option, which discards data outside of a given image region but losslessly preserves what is inside. Like the rotate and flip transforms, lossless crop is restricted by the current JPEG format; the upper left corner of the selected region must fall on an iMCU boundary. If it doesn't, then it is silently moved up and/or left to the nearest iMCU boundary (the lower right corner is unchanged.) Thus, the output image covers at least the requested region, but it may cover more. The adjustment of the region dimensions may be optionally disabled by attaching an The image can be losslessly cropped by giving the switch:
If W or H is larger than the width/height of the input image, then the output image is expanded in size, and the expanded region is filled in with zeros (neutral gray). Attaching an 'f' character ("flatten") to the width number will cause each block in the expanded region to be filled in with the DC coefficient of the nearest block in the input image rather than grayed out. Attaching an 'r' character ("reflect") to the width number will cause the expanded region to be filled in with repeated reflections of the input image rather than grayed out. A complementary lossless wipe option is provided to discard (gray out) data inside a given image region while losslessly preserving what is outside:
Attaching an 'f' character ("flatten") to the width number will cause the region to be filled with the average of adjacent blocks rather than grayed out. If the wipe region and the region outside the wipe region, when adjusted to the nearest iMCU boundary, form two horizontally adjacent rectangles, then attaching an 'r' character ("reflect") to the width number will cause the wipe region to be filled with repeated reflections of the outside region rather than grayed out. A lossless drop option is also provided, which allows another JPEG image to be inserted ("dropped") into the input image data at a given position, replacing the existing image data at that position:
Both the input image and the drop image must have the same subsampling level. It is best if they also have the same quantization (quality.) Otherwise, the quantization of the output image will be adapted to accommodate the higher of the input image quality and the drop image quality. The trim option can be used with the drop option to requantize the drop image to match the input image. Note that a grayscale image can be dropped into a full-color image or vice versa, as long as the full-color image has no vertical subsampling. If the input image is grayscale and the drop image is full-color, then the chrominance channels from the drop image will be discarded. Other not-strictly-lossless transformation switches are:
jpegtran also recognizes these switches that control what to do with "extra" markers, such as comment blocks:
The default behavior is -copy comments. (Note: in IJG releases v6 and v6a, jpegtran always did the equivalent of -copy none.) Additional switches recognized by jpegtran are:
EXAMPLESThis example converts a baseline JPEG file to progressive form:
This example rotates an image 90 degrees clockwise, discarding any unrotatable edge pixels:
ENVIRONMENT
SEE ALSOcjpeg(1), djpeg(1), rdjpgcom(1), wrjpgcom(1)Wallace, Gregory K. "The JPEG Still Picture Compression Standard", Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. AUTHORIndependent JPEG GroupThis file was modified by The libjpeg-turbo Project to include only information relevant to libjpeg-turbo and to wordsmith certain sections. BUGSThe transform options can't transform odd-size images perfectly. Use -trim or -perfect if you don't like the results.The entire image is read into memory and then written out again, even in cases where this isn't really necessary. Expect swapping on large images, especially when using the more complex transform options.
Visit the GSP FreeBSD Man Page Interface. |