|
kusano |
7d535a |
.TH JPEGTRAN 1 "28 December 2009"
|
|
kusano |
7d535a |
.SH NAME
|
|
kusano |
7d535a |
jpegtran \- lossless transformation of JPEG files
|
|
kusano |
7d535a |
.SH SYNOPSIS
|
|
kusano |
7d535a |
.B jpegtran
|
|
kusano |
7d535a |
[
|
|
kusano |
7d535a |
.I options
|
|
kusano |
7d535a |
]
|
|
kusano |
7d535a |
[
|
|
kusano |
7d535a |
.I filename
|
|
kusano |
7d535a |
]
|
|
kusano |
7d535a |
.LP
|
|
kusano |
7d535a |
.SH DESCRIPTION
|
|
kusano |
7d535a |
.LP
|
|
kusano |
7d535a |
.B jpegtran
|
|
kusano |
7d535a |
performs various useful transformations of JPEG files.
|
|
kusano |
7d535a |
It can translate the coded representation from one variant of JPEG to another,
|
|
kusano |
7d535a |
for example from baseline JPEG to progressive JPEG or vice versa. It can also
|
|
kusano |
7d535a |
perform some rearrangements of the image data, for example turning an image
|
|
kusano |
7d535a |
from landscape to portrait format by rotation.
|
|
kusano |
7d535a |
.PP
|
|
kusano |
7d535a |
.B jpegtran
|
|
kusano |
7d535a |
works by rearranging the compressed data (DCT coefficients), without
|
|
kusano |
7d535a |
ever fully decoding the image. Therefore, its transformations are lossless:
|
|
kusano |
7d535a |
there is no image degradation at all, which would not be true if you used
|
|
kusano |
7d535a |
.B djpeg
|
|
kusano |
7d535a |
followed by
|
|
kusano |
7d535a |
.B cjpeg
|
|
kusano |
7d535a |
to accomplish the same conversion. But by the same token,
|
|
kusano |
7d535a |
.B jpegtran
|
|
kusano |
7d535a |
cannot perform lossy operations such as changing the image quality.
|
|
kusano |
7d535a |
.PP
|
|
kusano |
7d535a |
.B jpegtran
|
|
kusano |
7d535a |
reads the named JPEG/JFIF file, or the standard input if no file is
|
|
kusano |
7d535a |
named, and produces a JPEG/JFIF file on the standard output.
|
|
kusano |
7d535a |
.SH OPTIONS
|
|
kusano |
7d535a |
All switch names may be abbreviated; for example,
|
|
kusano |
7d535a |
.B \-optimize
|
|
kusano |
7d535a |
may be written
|
|
kusano |
7d535a |
.B \-opt
|
|
kusano |
7d535a |
or
|
|
kusano |
7d535a |
.BR \-o .
|
|
kusano |
7d535a |
Upper and lower case are equivalent.
|
|
kusano |
7d535a |
British spellings are also accepted (e.g.,
|
|
kusano |
7d535a |
.BR \-optimise ),
|
|
kusano |
7d535a |
though for brevity these are not mentioned below.
|
|
kusano |
7d535a |
.PP
|
|
kusano |
7d535a |
To specify the coded JPEG representation used in the output file,
|
|
kusano |
7d535a |
.B jpegtran
|
|
kusano |
7d535a |
accepts a subset of the switches recognized by
|
|
kusano |
7d535a |
.BR cjpeg :
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-optimize
|
|
kusano |
7d535a |
Perform optimization of entropy encoding parameters.
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-progressive
|
|
kusano |
7d535a |
Create progressive JPEG file.
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.BI \-restart " N"
|
|
kusano |
7d535a |
Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is
|
|
kusano |
7d535a |
attached to the number.
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-arithmetic
|
|
kusano |
7d535a |
Use arithmetic coding.
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.BI \-scans " file"
|
|
kusano |
7d535a |
Use the scan script given in the specified text file.
|
|
kusano |
7d535a |
.PP
|
|
kusano |
7d535a |
See
|
|
kusano |
7d535a |
.BR cjpeg (1)
|
|
kusano |
7d535a |
for more details about these switches.
|
|
kusano |
7d535a |
If you specify none of these switches, you get a plain baseline-JPEG output
|
|
kusano |
7d535a |
file. The quality setting and so forth are determined by the input file.
|
|
kusano |
7d535a |
.PP
|
|
kusano |
7d535a |
The image can be losslessly transformed by giving one of these switches:
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-flip horizontal
|
|
kusano |
7d535a |
Mirror image horizontally (left-right).
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-flip vertical
|
|
kusano |
7d535a |
Mirror image vertically (top-bottom).
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-rotate 90
|
|
kusano |
7d535a |
Rotate image 90 degrees clockwise.
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-rotate 180
|
|
kusano |
7d535a |
Rotate image 180 degrees.
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-rotate 270
|
|
kusano |
7d535a |
Rotate image 270 degrees clockwise (or 90 ccw).
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-transpose
|
|
kusano |
7d535a |
Transpose image (across UL-to-LR axis).
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-transverse
|
|
kusano |
7d535a |
Transverse transpose (across UR-to-LL axis).
|
|
kusano |
7d535a |
.IP
|
|
kusano |
7d535a |
The transpose transformation has no restrictions regarding image dimensions.
|
|
kusano |
7d535a |
The other transformations operate rather oddly if the image dimensions are not
|
|
kusano |
7d535a |
a multiple of the iMCU size (usually 8 or 16 pixels), because they can only
|
|
kusano |
7d535a |
transform complete blocks of DCT coefficient data in the desired way.
|
|
kusano |
7d535a |
.IP
|
|
kusano |
7d535a |
.BR jpegtran 's
|
|
kusano |
7d535a |
default behavior when transforming an odd-size image is designed
|
|
kusano |
7d535a |
to preserve exact reversibility and mathematical consistency of the
|
|
kusano |
7d535a |
transformation set. As stated, transpose is able to flip the entire image
|
|
kusano |
7d535a |
area. Horizontal mirroring leaves any partial iMCU column at the right edge
|
|
kusano |
7d535a |
untouched, but is able to flip all rows of the image. Similarly, vertical
|
|
kusano |
7d535a |
mirroring leaves any partial iMCU row at the bottom edge untouched, but is
|
|
kusano |
7d535a |
able to flip all columns. The other transforms can be built up as sequences
|
|
kusano |
7d535a |
of transpose and flip operations; for consistency, their actions on edge
|
|
kusano |
7d535a |
pixels are defined to be the same as the end result of the corresponding
|
|
kusano |
7d535a |
transpose-and-flip sequence.
|
|
kusano |
7d535a |
.IP
|
|
kusano |
7d535a |
For practical use, you may prefer to discard any untransformable edge pixels
|
|
kusano |
7d535a |
rather than having a strange-looking strip along the right and/or bottom edges
|
|
kusano |
7d535a |
of a transformed image. To do this, add the
|
|
kusano |
7d535a |
.B \-trim
|
|
kusano |
7d535a |
switch:
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-trim
|
|
kusano |
7d535a |
Drop non-transformable edge blocks.
|
|
kusano |
7d535a |
.IP
|
|
kusano |
7d535a |
Obviously, a transformation with
|
|
kusano |
7d535a |
.B \-trim
|
|
kusano |
7d535a |
is not reversible, so strictly speaking
|
|
kusano |
7d535a |
.B jpegtran
|
|
kusano |
7d535a |
with this switch is not lossless. Also, the expected mathematical
|
|
kusano |
7d535a |
equivalences between the transformations no longer hold. For example,
|
|
kusano |
7d535a |
.B \-rot 270 -trim
|
|
kusano |
7d535a |
trims only the bottom edge, but
|
|
kusano |
7d535a |
.B \-rot 90 -trim
|
|
kusano |
7d535a |
followed by
|
|
kusano |
7d535a |
.B \-rot 180 -trim
|
|
kusano |
7d535a |
trims both edges.
|
|
kusano |
7d535a |
.IP
|
|
kusano |
7d535a |
If you are only interested in perfect transformation, add the
|
|
kusano |
7d535a |
.B \-perfect
|
|
kusano |
7d535a |
switch:
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-perfect
|
|
kusano |
7d535a |
Fails with an error if the transformation is not perfect.
|
|
kusano |
7d535a |
.IP
|
|
kusano |
7d535a |
For example you may want to do
|
|
kusano |
7d535a |
.IP
|
|
kusano |
7d535a |
.B (jpegtran \-rot 90 -perfect
|
|
kusano |
7d535a |
.I foo.jpg
|
|
kusano |
7d535a |
.B || djpeg
|
|
kusano |
7d535a |
.I foo.jpg
|
|
kusano |
7d535a |
.B | pnmflip \-r90 | cjpeg)
|
|
kusano |
7d535a |
.IP
|
|
kusano |
7d535a |
to do a perfect rotation if available or an approximated one if not.
|
|
kusano |
7d535a |
.PP
|
|
kusano |
7d535a |
We also offer a lossless-crop option, which discards data outside a given
|
|
kusano |
7d535a |
image region but losslessly preserves what is inside. Like the rotate and
|
|
kusano |
7d535a |
flip transforms, lossless crop is restricted by the current JPEG format: the
|
|
kusano |
7d535a |
upper left corner of the selected region must fall on an iMCU boundary. If
|
|
kusano |
7d535a |
this does not hold for the given crop parameters, we silently move the upper
|
|
kusano |
7d535a |
left corner up and/or left to make it so, simultaneously increasing the region
|
|
kusano |
7d535a |
dimensions to keep the lower right crop corner unchanged. (Thus, the output
|
|
kusano |
7d535a |
image covers at least the requested region, but may cover more.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The image can be losslessly cropped by giving the switch:
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-crop WxH+X+Y
|
|
kusano |
7d535a |
Crop to a rectangular subarea of width W, height H starting at point X,Y.
|
|
kusano |
7d535a |
.PP
|
|
kusano |
7d535a |
Other not-strictly-lossless transformation switches are:
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-grayscale
|
|
kusano |
7d535a |
Force grayscale output.
|
|
kusano |
7d535a |
.IP
|
|
kusano |
7d535a |
This option discards the chrominance channels if the input image is YCbCr
|
|
kusano |
7d535a |
(ie, a standard color JPEG), resulting in a grayscale JPEG file. The
|
|
kusano |
7d535a |
luminance channel is preserved exactly, so this is a better method of reducing
|
|
kusano |
7d535a |
to grayscale than decompression, conversion, and recompression. This switch
|
|
kusano |
7d535a |
is particularly handy for fixing a monochrome picture that was mistakenly
|
|
kusano |
7d535a |
encoded as a color JPEG. (In such a case, the space savings from getting rid
|
|
kusano |
7d535a |
of the near-empty chroma channels won't be large; but the decoding time for
|
|
kusano |
7d535a |
a grayscale JPEG is substantially less than that for a color JPEG.)
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.BI \-scale " M/N"
|
|
kusano |
7d535a |
Scale the output image by a factor M/N.
|
|
kusano |
7d535a |
.IP
|
|
kusano |
7d535a |
Currently supported scale factors are M/N with all M from 1 to 16, where N is
|
|
kusano |
7d535a |
the source DCT size, which is 8 for baseline JPEG. If the /N part is omitted,
|
|
kusano |
7d535a |
then M specifies the DCT scaled size to be applied on the given input. For
|
|
kusano |
7d535a |
baseline JPEG this is equivalent to M/8 scaling, since the source DCT size
|
|
kusano |
7d535a |
for baseline JPEG is 8.
|
|
kusano |
7d535a |
.B Caution:
|
|
kusano |
7d535a |
An implementation of the JPEG SmartScale extension is required for this
|
|
kusano |
7d535a |
feature. SmartScale enabled JPEG is not yet widely implemented, so many
|
|
kusano |
7d535a |
decoders will be unable to view a SmartScale extended JPEG file at all.
|
|
kusano |
7d535a |
.PP
|
|
kusano |
7d535a |
.B jpegtran
|
|
kusano |
7d535a |
also recognizes these switches that control what to do with "extra" markers,
|
|
kusano |
7d535a |
such as comment blocks:
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-copy none
|
|
kusano |
7d535a |
Copy no extra markers from source file. This setting suppresses all
|
|
kusano |
7d535a |
comments and other excess baggage present in the source file.
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-copy comments
|
|
kusano |
7d535a |
Copy only comment markers. This setting copies comments from the source file,
|
|
kusano |
7d535a |
but discards any other inessential (for image display) data.
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-copy all
|
|
kusano |
7d535a |
Copy all extra markers. This setting preserves miscellaneous markers
|
|
kusano |
7d535a |
found in the source file, such as JFIF thumbnails, Exif data, and Photoshop
|
|
kusano |
7d535a |
settings. In some files these extra markers can be sizable.
|
|
kusano |
7d535a |
.IP
|
|
kusano |
7d535a |
The default behavior is
|
|
kusano |
7d535a |
.BR "\-copy comments" .
|
|
kusano |
7d535a |
(Note: in IJG releases v6 and v6a,
|
|
kusano |
7d535a |
.B jpegtran
|
|
kusano |
7d535a |
always did the equivalent of
|
|
kusano |
7d535a |
.BR "\-copy none" .)
|
|
kusano |
7d535a |
.PP
|
|
kusano |
7d535a |
Additional switches recognized by jpegtran are:
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.BI \-maxmemory " N"
|
|
kusano |
7d535a |
Set limit for amount of memory to use in processing large images. Value is
|
|
kusano |
7d535a |
in thousands of bytes, or millions of bytes if "M" is attached to the
|
|
kusano |
7d535a |
number. For example,
|
|
kusano |
7d535a |
.B \-max 4m
|
|
kusano |
7d535a |
selects 4000000 bytes. If more space is needed, temporary files will be used.
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.BI \-outfile " name"
|
|
kusano |
7d535a |
Send output image to the named file, not to standard output.
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-verbose
|
|
kusano |
7d535a |
Enable debug printout. More
|
|
kusano |
7d535a |
.BR \-v 's
|
|
kusano |
7d535a |
give more output. Also, version information is printed at startup.
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B \-debug
|
|
kusano |
7d535a |
Same as
|
|
kusano |
7d535a |
.BR \-verbose .
|
|
kusano |
7d535a |
.SH EXAMPLES
|
|
kusano |
7d535a |
.LP
|
|
kusano |
7d535a |
This example converts a baseline JPEG file to progressive form:
|
|
kusano |
7d535a |
.IP
|
|
kusano |
7d535a |
.B jpegtran \-progressive
|
|
kusano |
7d535a |
.I foo.jpg
|
|
kusano |
7d535a |
.B >
|
|
kusano |
7d535a |
.I fooprog.jpg
|
|
kusano |
7d535a |
.PP
|
|
kusano |
7d535a |
This example rotates an image 90 degrees clockwise, discarding any
|
|
kusano |
7d535a |
unrotatable edge pixels:
|
|
kusano |
7d535a |
.IP
|
|
kusano |
7d535a |
.B jpegtran \-rot 90 -trim
|
|
kusano |
7d535a |
.I foo.jpg
|
|
kusano |
7d535a |
.B >
|
|
kusano |
7d535a |
.I foo90.jpg
|
|
kusano |
7d535a |
.SH ENVIRONMENT
|
|
kusano |
7d535a |
.TP
|
|
kusano |
7d535a |
.B JPEGMEM
|
|
kusano |
7d535a |
If this environment variable is set, its value is the default memory limit.
|
|
kusano |
7d535a |
The value is specified as described for the
|
|
kusano |
7d535a |
.B \-maxmemory
|
|
kusano |
7d535a |
switch.
|
|
kusano |
7d535a |
.B JPEGMEM
|
|
kusano |
7d535a |
overrides the default value specified when the program was compiled, and
|
|
kusano |
7d535a |
itself is overridden by an explicit
|
|
kusano |
7d535a |
.BR \-maxmemory .
|
|
kusano |
7d535a |
.SH SEE ALSO
|
|
kusano |
7d535a |
.BR cjpeg (1),
|
|
kusano |
7d535a |
.BR djpeg (1),
|
|
kusano |
7d535a |
.BR rdjpgcom (1),
|
|
kusano |
7d535a |
.BR wrjpgcom (1)
|
|
kusano |
7d535a |
.br
|
|
kusano |
7d535a |
Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
|
|
kusano |
7d535a |
Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
|
|
kusano |
7d535a |
.SH AUTHOR
|
|
kusano |
7d535a |
Independent JPEG Group
|
|
kusano |
7d535a |
.SH BUGS
|
|
kusano |
7d535a |
The transform options can't transform odd-size images perfectly. Use
|
|
kusano |
7d535a |
.B \-trim
|
|
kusano |
7d535a |
or
|
|
kusano |
7d535a |
.B \-perfect
|
|
kusano |
7d535a |
if you don't like the results.
|
|
kusano |
7d535a |
.PP
|
|
kusano |
7d535a |
The entire image is read into memory and then written out again, even in
|
|
kusano |
7d535a |
cases where this isn't really necessary. Expect swapping on large images,
|
|
kusano |
7d535a |
especially when using the more complex transform options.
|