1JPEGTRAN(1)                 General Commands Manual                JPEGTRAN(1)
2
3
4

NAME

6       jpegtran - lossless transformation of JPEG files
7

SYNOPSIS

9       jpegtran [ options ] [ filename ]
10

DESCRIPTION

12       jpegtran performs various useful transformations of JPEG files.  It can
13       translate the coded representation from one variant of JPEG to another,
14       for  example  from baseline JPEG to progressive JPEG or vice versa.  It
15       can also perform some rearrangements of the  image  data,  for  example
16       turning an image from landscape to portrait format by rotation.
17
18       jpegtran  works  by rearranging the compressed data (DCT coefficients),
19       without ever fully decoding the image.  Therefore, its  transformations
20       are  lossless: there is no image degradation at all, which would not be
21       true if you used djpeg followed by cjpeg to accomplish the same conver‐
22       sion.   But by the same token, jpegtran cannot perform lossy operations
23       such as changing the image quality.
24
25       jpegtran reads the named JPEG/JFIF file, or the standard  input  if  no
26       file is named, and produces a JPEG/JFIF file on the standard output.
27

OPTIONS

29       All  switch  names  may  be  abbreviated; for example, -optimize may be
30       written -opt or -o.  Upper and  lower  case  are  equivalent.   British
31       spellings are also accepted (e.g., -optimise), though for brevity these
32       are not mentioned below.
33
34       To specify the coded JPEG representation used in the output file, jpeg‐
35       tran accepts a subset of the switches recognized by cjpeg:
36
37       -optimize
38              Perform optimization of entropy encoding parameters.
39
40       -progressive
41              Create progressive JPEG file.
42
43       -restart N
44              Emit  a  JPEG  restart  marker  every N MCU rows, or every N MCU
45              blocks if "B" is attached to the number.
46
47       -scans file
48              Use the scan script given in the specified text file.
49
50       See cjpeg(1) for more details about these  switches.   If  you  specify
51       none of these switches, you get a plain baseline-JPEG output file.  The
52       quality setting and so forth are determined by the input file.
53
54       The image  can  be  losslessly  transformed  by  giving  one  of  these
55       switches:
56
57       -flip horizontal
58              Mirror image horizontally (left-right).
59
60       -flip vertical
61              Mirror image vertically (top-bottom).
62
63       -rotate 90
64              Rotate image 90 degrees clockwise.
65
66       -rotate 180
67              Rotate image 180 degrees.
68
69       -rotate 270
70              Rotate image 270 degrees clockwise (or 90 ccw).
71
72       -transpose
73              Transpose image (across UL-to-LR axis).
74
75       -transverse
76              Transverse transpose (across UR-to-LL axis).
77
78       The transpose transformation has no restrictions regarding image dimen‐
79       sions.  The other transformations operate rather  oddly  if  the  image
80       dimensions  are  not  a multiple of the iMCU size (usually 8 or 16 pix‐
81       els), because they can only transform complete blocks  of  DCT  coeffi‐
82       cient data in the desired way.
83
84       jpegtran's  default  behavior  when  transforming  an odd-size image is
85       designed to preserve exact reversibility and  mathematical  consistency
86       of  the  transformation  set.  As stated, transpose is able to flip the
87       entire image area.  Horizontal mirroring leaves any partial iMCU column
88       at the right edge untouched, but is able to flip all rows of the image.
89       Similarly, vertical mirroring leaves any partial iMCU row at the bottom
90       edge  untouched, but is able to flip all columns.  The other transforms
91       can be built up as sequences of transpose and flip operations; for con‐
92       sistency,  their  actions  on edge pixels are defined to be the same as
93       the end result of the corresponding transpose-and-flip sequence.
94
95       For practical use, you may prefer to discard any  untransformable  edge
96       pixels  rather  than  having  a  strange-looking  strip along the right
97       and/or bottom edges of a transformed image.  To do this, add the  -trim
98       switch:
99
100       -trim  Drop non-transformable edge blocks.
101
102       Obviously,  a  transformation with -trim is not reversible, so strictly
103       speaking jpegtran with this switch is not lossless.  Also, the expected
104       mathematical  equivalences  between the transformations no longer hold.
105       For example, -rot 270 -trim trims only the bottom  edge,  but  -rot  90
106       -trim followed by -rot 180 -trim trims both edges.
107
108       Another not-strictly-lossless transformation switch is:
109
110       -grayscale
111              Force grayscale output.
112
113       This  option  discards  the  chrominance channels if the input image is
114       YCbCr (ie, a standard color JPEG), resulting in a grayscale JPEG  file.
115       The  luminance channel is preserved exactly, so this is a better method
116       of reducing to grayscale than decompression, conversion, and recompres‐
117       sion.   This  switch is particularly handy for fixing a monochrome pic‐
118       ture that was mistakenly encoded as a color JPEG.  (In such a case, the
119       space  savings from getting rid of the near-empty chroma channels won't
120       be large; but the decoding time for a grayscale JPEG  is  substantially
121       less than that for a color JPEG.)
122
123       jpegtran  also  recognizes  these switches that control what to do with
124       "extra" markers, such as comment blocks:
125
126       -copy none
127              Copy no extra markers from source file.  This setting suppresses
128              all  comments  and  other  excess  baggage present in the source
129              file.
130
131       -copy comments
132              Copy only comment markers.  This setting  copies  comments  from
133              the source file, but discards any other inessential data.
134
135       -copy all
136              Copy  all  extra  markers.  This setting preserves miscellaneous
137              markers found in the source file, such as  JFIF  thumbnails  and
138              Photoshop  settings.   In  some files these extra markers can be
139              sizable.
140
141       The default behavior is -copy comments.  (Note: in IJG releases v6  and
142       v6a, jpegtran always did the equivalent of -copy none.)
143
144       Additional switches recognized by jpegtran are:
145
146       -maxmemory N
147              Set  limit  for  amount  of  memory  to  use in processing large
148              images.  Value is in thousands of bytes, or millions of bytes if
149              "M"  is  attached  to  the number.  For example, -max 4m selects
150              4000000 bytes.  If more space is needed, temporary files will be
151              used.
152
153       -outfile name
154              Send output image to the named file, not to standard output.
155
156       -verbose
157              Enable  debug printout.  More -v's give more output.  Also, ver‐
158              sion information is printed at startup.
159
160       -debug Same as -verbose.
161

EXAMPLES

163       This example converts a baseline JPEG file to progressive form:
164
165              jpegtran -progressive foo.jpg > fooprog.jpg
166
167       This example rotates an image  90  degrees  clockwise,  discarding  any
168       unrotatable edge pixels:
169
170              jpegtran -rot 90 -trim foo.jpg > foo90.jpg
171

ENVIRONMENT

173       JPEGMEM
174              If  this  environment  variable is set, its value is the default
175              memory limit.  The value  is  specified  as  described  for  the
176              -maxmemory  switch.   JPEGMEM overrides the default value speci‐
177              fied when the program was compiled, and itself is overridden  by
178              an explicit -maxmemory.
179

SEE ALSO

181       cjpeg(1), djpeg(1), rdjpgcom(1), wrjpgcom(1)
182       Wallace,  Gregory  K.   "The  JPEG Still Picture Compression Standard",
183       Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
184

AUTHOR

186       Independent JPEG Group
187

BUGS

189       Arithmetic coding is not supported for legal reasons.
190
191       The transform options can't transform odd-size images  perfectly.   Use
192       -trim if you don't like the results without it.
193
194       The  entire  image is read into memory and then written out again, even
195       in cases where this isn't really necessary.  Expect swapping  on  large
196       images, especially when using the more complex transform options.
197
198
199
200                                 3 August 1997                     JPEGTRAN(1)
Impressum