User Commands jpegtran(1)
NAME
jpegtran - lossless transformation of JPEG files
SYNOPSIS
jpegtran [options] [filename]
DESCRIPTION
jpegtran performs various useful transformations of JPEG
files. jpegtran can translate the coded representation from
one variant of JPEG to another, for example from baselineJPEG to progressive JPEG or vice versa. jpegtran can also
perform some rearrangements of the image data, for exampleturning an image from landscape to portrait format by rota-
tion.jpegtran works by rearranging the compressed data (DCT coef-
ficients), without ever fully decoding the image. Therefore,jpegtran 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.However, jpegtran cannot perform lossy operations such as
changing the image quality.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. OPTIONS
All options may be abbreviated. For example, -optimize may
be written -opt or -o. Upper and lower case are equivalent.
British spellings are also accepted. For example, -optimise.
The following options are supported:-copy all Copy all extra markers. This option
preserves miscellaneous markers found in the source file, such asJFIF thumbnails and source-
application settings. In some files, these extra markers can be sizable.-copy comments Copy only comment markers. This
option copies comments from the source file, but discards any other inessential data. This is the default.SunOS 5.11 Last change: 26 Mar 2004 1
User Commands jpegtran(1)
-copy none Copy no extra markers from the
source file. This option suppressesall comments and other excess infor-
mation present in the source file.-flip horizontal Create a mirror image horizontally,
that is, from left to right. This is a lossless transformation.-flip vertical Create a mirror image vertically,
that is, from top to bottom. This is a lossless transformation.-grayscale Force grayscale output. This is not
a lossless transformation. For moreinformation about the -grayscale
option, see the Extended Description section.-maxmemory N Set the limit for the amount of
memory to use in processing large images. N is specified in thousands of bytes, or in millions of bytes if "M" is specified with the number.For example, -max 4m selects 4000000
bytes. If more space is needed, tem-
porary files are used.-optimize Optimize the entropy encoding param-
eters. For more information aboutthe -optimize option, see cjpeg(1).
-outfile name Send the output image to the named
file, instead of to the standard output.-progressive Create a progressive JPEG file. For
more information about theSunOS 5.11 Last change: 26 Mar 2004 2
User Commands jpegtran(1)
-progressive option, see cjpeg(1).
-restart N Emit a JPEG restart marker every N
MCU rows, or every N MCU blocks if "B" is specified with the number.For more information about the -res-
tart option, see cjpeg(1).-rotate 90 Rotate the image 90 degrees clock-
wise. This is a lossless transforma-
tion.-rotate 180 Rotate the image 180 degrees clock-
wise. This is a lossless transforma-
tion.-rotate 270 Rotate the image 270 degrees clock-
wise, or 90 degrees anticlockwise. This is a lossless transformation.-scans file Use the scan script provided in the
specified text file.-transpose Transpose the image, that is, across
the UL-to-LR axis. This is a loss-
less transformation. For moreinformation about the -transpose
option, see the Extended Description section.-transverse Transverse transpose the image, that
is, across the UR-to-LL axis. This
is a lossless transformation.-trim Drop non-transformable edge blocks.
This is not a losslessSunOS 5.11 Last change: 26 Mar 2004 3
User Commands jpegtran(1)
transformation. For more informationabout the -trim option, see the
Extended Description section.-verbose Display version information at
startup, and enable debug printout.The -vv option displays more verbose
output than the -v option. The -vvv
option displays the most verbose output.You can also use -debug to specify
this option. OPERANDS The following operands are supported: filename The name of the JPEG file to be transformed.EXTENDED DESCRIPTION
If you do not specify one of the following options, you geta plain baseline-JPEG output file: -optimize, -progressive,
-restart N, -scans file. In such cases, the quality setting
and other settings are determined by the input file. Lossless Transformations The transpose transformation has no restrictions as regards image dimensions. The other transformations operate rather oddly if the image dimensions are not a multiple of the iMCU siz, usually 8 or 16 pixels, because they can only transform complete blocks of DCT coefficient data in the desired way.The default behavior when transforming an odd-size image is
designed to preserve exact reversibility and mathematical consistency of the transformation set.As stated, transpose can flip the entire image area. Hor-
izontal 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 tran-
spose and flip operations. For consistency, their actions on edge pixels are defined to be the same as the end result ofSunOS 5.11 Last change: 26 Mar 2004 4
User Commands jpegtran(1)
the corresponding transpose-and-flip sequence.
Not-Lossless Transformations
You may prefer to discard any untransformable edge pixelsrather than have a strange-looking strip along the right or
bottom edges of a transformed image. To do this, use the-trim option. Obviously, a transformation with -trim is not
reversible, so strictly speaking jpegtran with this option
is not lossless. Also, the expected mathematical equivalences between the transformations no longer hold. Forexample, -rot 270 -trim trims only the bottom edge, but -rot
90 -trim followed by -rot 180 -trim trims both edges.
Another not-strictly-lossless transformation option is
-grayscale. This option discards the chrominance channels if
the input image is YCbCr (that is, a standard color JPEG),which results in a grayscale JPEG file. The luminance chan-
nel is preserved exactly, so this is a better method of reducing to grayscale than decompression, conversion, andrecompression. The -grayscale option is particularly useful
for fixing a monochrome picture that was mistakenly encodedas a color JPEG. In such a case, the space saved by discard-
ing the near-empty chrominance channels is not large, but
the decoding time for a grayscale JPEG is substantially less than that for a color JPEG.EXAMPLES
Example 1: Converting a Baseline JPEG File to Progressive Formexample% jpegtran -progressive test.jpg > testprog.jpg
Example 2: Rotating an Image 90 Degrees Clockwise, Discard-
ing Any Unrotatable Edge Pixelsexample% jpegtran rot 90 -trim test.jpg > test90.jpg
ENVIRONMENT VARIABLESjpegtran uses the following environment variables:
JPEGMEM The value of this environment vari-
able, if set, is the default memory limit. The value is specified asdescribed for the -maxmemory option.
JPEGMEM overrides the default valuespecified when the program was com-
piled, and is in turn overridden byan explicit -maxmemory option.
SunOS 5.11 Last change: 26 Mar 2004 5
User Commands jpegtran(1)
ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:____________________________________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|_____________________________|_____________________________|
| Availability | image/library/libjpeg ||_____________________________|_____________________________|
| Interface stability | Uncommitted ||_____________________________|_____________________________|
SEE ALSO
Wallace, Gregory K., The JPEG Still Picture Compression Standard Communications of the ACM, April 1991 (vol. 34, no.4), pp. 30-44.
cjpeg(1), djpeg(1), rdjpgcom(1), wrjpgcom(1) NOTES Arithmetic coding is not supported. The entire image is read into memory and then written out again, even in cases where this is not really necessary. Expect swapping on large images, especially when using the more complex transform options. This man page was originally written by the Independent JPEG Group. Updated by Breda McColgan, Sun Microsystems Inc., 2004.SunOS 5.11 Last change: 26 Mar 2004 6