MAN page from CentOS 7 mozjpeg-master-20170714.2.x86_64.rpm


Section: User Commands (1)
Updated: 18 March 2017


jpegtran - lossless transformation of JPEG files 





jpegtranperforms 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 alsoperform some rearrangements of the image data, for example turning an imagefrom landscape to portrait format by rotation.

For EXIF files and JPEG files containing Exif data, you may prefer to useexiftraninstead.

jpegtranworks by rearranging the compressed data (DCT coefficients), withoutever fully decoding the image. Therefore, its transformations are lossless:there is no image degradation at all, which would not be true if you useddjpegfollowed bycjpegto accomplish the same conversion. But by the same token,jpegtrancannot perform lossy operations such as changing the image quality. However,while the image data is losslessly transformed, metadata can be removed. Seethe-copyoption for specifics.

jpegtranreads the named JPEG/JFIF file, or the standard input if no file isnamed, and produces a JPEG/JFIF file on the standard output. 


All switch names may be abbreviated; for example,-optimizemay be written-optor-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,jpegtranaccepts a subset of the switches recognized bycjpeg:

Perform optimization of entropy encoding parameters.
Create progressive JPEG file.
-restart N
Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" isattached to the number.
Use arithmetic coding.
-scans file
Use the scan script given in the specified text file.

Seecjpeg(1)for more details about these switches.If you specify none of these switches, you get a plain baseline-JPEG outputfile. The quality setting and so forth are determined by the input file.

The image can be losslessly transformed by giving one of these switches:

-flip horizontal
Mirror image horizontally (left-right).
-flip vertical
Mirror image vertically (top-bottom).
-rotate 90
Rotate image 90 degrees clockwise.
-rotate 180
Rotate image 180 degrees.
-rotate 270
Rotate image 270 degrees clockwise (or 90 ccw).
Transpose image (across UL-to-LR axis).
Transverse transpose (across UR-to-LL axis).

The transpose transformation has no restrictions regarding image dimensions.The other transformations operate rather oddly if the image dimensions are nota multiple of the iMCU size (usually 8 or 16 pixels), because they can onlytransform complete blocks of DCT coefficient data in the desired way.

jpegtran'sdefault behavior when transforming an odd-size image is designedto preserve exact reversibility and mathematical consistency of thetransformation set. As stated, transpose is able to flip the entire imagearea. Horizontal mirroring leaves any partial iMCU column at the right edgeuntouched, but is able to flip all rows of the image. Similarly, verticalmirroring leaves any partial iMCU row at the bottom edge untouched, but isable to flip all columns. The other transforms can be built up as sequencesof transpose and flip operations; for consistency, their actions on edgepixels are defined to be the same as the end result of the correspondingtranspose-and-flip sequence.

For practical use, you may prefer to discard any untransformable edge pixelsrather than having a strange-looking strip along the right and/or bottom edgesof a transformed image. To do this, add the-trimswitch:

Drop non-transformable edge blocks.
Obviously, a transformation with-trimis not reversible, so strictly speakingjpegtranwith this switch is not lossless. Also, the expected mathematicalequivalences between the transformations no longer hold. For example,-rot 270 -trimtrims only the bottom edge, but-rot 90 -trimfollowed by-rot 180 -trimtrims both edges.
If you are only interested in perfect transformations, add the-perfectswitch. This causesjpegtranto fail with an error if the transformation is not perfect.
For example, you may want to do
(jpegtran -rot 90 -perfectfoo.jpg|| djpegfoo.jpg| pnmflip -r90 | cjpeg)
to do a perfect rotation, if available, or an approximated one if not.

This version of jpegtran also offers a lossless crop option, whichdiscards data outside of a given image region but losslessly preserves what isinside. Like the rotate and flip transforms, lossless crop is restricted by thecurrent JPEG format; the upper left corner of the selected region must fall onan iMCU boundary. If it doesn't, then it is silently moved up and/or left tothe nearest iMCU boundary (the lower right corner is unchanged.) Thus, theoutput image covers at least the requested region, but it may cover more. Theadjustment of the region dimensions may be optionally disabled by attachingan 'f' character ("force") to the width or height number.

The image can be losslessly cropped by giving the switch:

-crop WxH+X+Y
Crop the image to a rectangular region of width W and height H, starting atpoint X,Y. The lossless crop feature discards data outside of a given imageregion but losslessly preserves what is inside. Like the rotate and fliptransforms, lossless crop is restricted by the current JPEG format; the upperleft corner of the selected region must fall on an iMCU boundary. If itdoesn't, then it is silently moved up and/or left to the nearest iMCU boundary(the lower right corner is unchanged.)

Other not-strictly-lossless transformation switches are:

Force grayscale output.
This option discards the chrominance channels if the input image is YCbCr(ie, a standard color JPEG), resulting in a grayscale JPEG file. Theluminance channel is preserved exactly, so this is a better method of reducingto grayscale than decompression, conversion, and recompression. This switchis particularly handy for fixing a monochrome picture that was mistakenlyencoded as a color JPEG. (In such a case, the space savings from getting ridof the near-empty chroma channels won't be large; but the decoding time fora grayscale JPEG is substantially less than that for a color JPEG.)

jpegtranalso recognizes these switches that control what to do with "extra" markers,such as comment blocks:

-copy none
Copy no extra markers from source file. This setting suppresses allcomments and other metadata in the source file.
-copy comments
Copy only comment markers. This setting copies comments from the source filebut discards any other metadata.
-copy all
Copy all extra markers. This setting preserves miscellaneous markersfound in the source file, such as JFIF thumbnails, Exif data, and Photoshopsettings. In some files, these extra markers can be sizable. Note that thisoption will copy thumbnails as-is; they will not be transformed.

The default behavior is -copy comments. (Note: in IJG releases v6 andv6a, jpegtran always did the equivalent of -copy none.)

Additional switches recognized by jpegtran are:

-maxmemory N
Set limit for amount of memory to use in processing large images. Value isin thousands of bytes, or millions of bytes if "M" is attached to thenumber. For example,-max 4mselects 4000000 bytes. If more space is needed, an error will occur.
-outfile name
Send output image to the named file, not to standard output.
Enable debug printout. More-v'sgive more output. Also, version information is printed at startup.
Same as-verbose.
Print version information and exit.


This example converts a baseline JPEG file to progressive form:

jpegtran -progressivefoo.jpg>fooprog.jpg

This example rotates an image 90 degrees clockwise, discarding anyunrotatable edge pixels:

jpegtran -rot 90 -trimfoo.jpg>foo90.jpg


If this environment variable is set, its value is the default memory limit.The value is specified as described for the-maxmemoryswitch.JPEGMEMoverrides the default value specified when the program was compiled, anditself is overridden by an explicit-maxmemory.


Wallace, Gregory K. "The JPEG Still Picture Compression Standard",Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. 


Independent JPEG Group

This file was modified by The libjpeg-turbo Project to include only informationrelevant to libjpeg-turbo and to wordsmith certain sections. 


The transform options can't transform odd-size images perfectly. Use-trimor-perfectif you don't like the results.

The entire image is read into memory and then written out again, even incases where this isn't really necessary. Expect swapping on large images,especially when using the more complex transform options.




This document was created byman2html,using the manual pages.