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