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       -arithmetic
48              Use arithmetic coding.
49
50       -scans file
51              Use the scan script given in the specified text file.
52
53       See cjpeg(1) for more details about these  switches.   If  you  specify
54       none of these switches, you get a plain baseline-JPEG output file.  The
55       quality setting and so forth are determined by the input file.
56
57       The image  can  be  losslessly  transformed  by  giving  one  of  these
58       switches:
59
60       -flip horizontal
61              Mirror image horizontally (left-right).
62
63       -flip vertical
64              Mirror image vertically (top-bottom).
65
66       -rotate 90
67              Rotate image 90 degrees clockwise.
68
69       -rotate 180
70              Rotate image 180 degrees.
71
72       -rotate 270
73              Rotate image 270 degrees clockwise (or 90 ccw).
74
75       -transpose
76              Transpose image (across UL-to-LR axis).
77
78       -transverse
79              Transverse transpose (across UR-to-LL axis).
80
81       The transpose transformation has no restrictions regarding image dimen‐
82       sions.  The other transformations operate rather  oddly  if  the  image
83       dimensions  are  not  a multiple of the iMCU size (usually 8 or 16 pix‐
84       els), because they can only transform complete blocks  of  DCT  coeffi‐
85       cient data in the desired way.
86
87       jpegtran's  default  behavior  when  transforming  an odd-size image is
88       designed to preserve exact reversibility and  mathematical  consistency
89       of  the  transformation  set.  As stated, transpose is able to flip the
90       entire image area.  Horizontal mirroring leaves any partial iMCU column
91       at the right edge untouched, but is able to flip all rows of the image.
92       Similarly, vertical mirroring leaves any partial iMCU row at the bottom
93       edge  untouched, but is able to flip all columns.  The other transforms
94       can be built up as sequences of transpose and flip operations; for con‐
95       sistency,  their  actions  on edge pixels are defined to be the same as
96       the end result of the corresponding transpose-and-flip sequence.
97
98       For practical use, you may prefer to discard any  untransformable  edge
99       pixels  rather  than  having  a  strange-looking  strip along the right
100       and/or bottom edges of a transformed image.  To do this, add the  -trim
101       switch:
102
103       -trim  Drop non-transformable edge blocks.
104
105              Obviously,  a  transformation  with  -trim is not reversible, so
106              strictly speaking jpegtran with this  switch  is  not  lossless.
107              Also,  the expected mathematical equivalences between the trans‐
108              formations no longer hold.  For example, -rot  270  -trim  trims
109              only  the  bottom  edge,  but -rot 90 -trim followed by -rot 180
110              -trim trims both edges.
111
112       -perfect
113              If you are only interested in perfect transformations,  add  the
114              -perfect  switch.  This causes jpegtran to fail with an error if
115              the transformation is not perfect.
116
117              For example, you may want to do
118
119              (jpegtran -rot 90 -perfect foo.jpg || djpeg  foo.jpg  |  pnmflip
120              -r90 | cjpeg)
121
122              to  do  a perfect rotation, if available, or an approximated one
123              if not.
124
125       -crop WxH+X+Y
126              Crop the image to a rectangular region of width W and height  H,
127              starting  at point X,Y.  The lossless crop feature discards data
128              outside of a given image region but losslessly preserves what is
129              inside.   Like  the rotate and flip transforms, lossless crop is
130              restricted by the current JPEG format; the upper left corner  of
131              the  selected  region  must  fall  on  an  iMCU boundary.  If it
132              doesn't, then it is silently moved up and/or left to the nearest
133              iMCU boundary (the lower right corner is unchanged.)
134
135       Other not-strictly-lossless transformation switches are:
136
137       -grayscale
138              Force grayscale output.
139
140              This option discards the chrominance channels if the input image
141              is YCbCr (ie, a standard color JPEG), resulting in  a  grayscale
142              JPEG  file.  The luminance channel is preserved exactly, so this
143              is a better method of reducing to grayscale than  decompression,
144              conversion,  and  recompression.   This  switch  is particularly
145              handy for  fixing  a  monochrome  picture  that  was  mistakenly
146              encoded  as  a  color  JPEG.  (In such a case, the space savings
147              from getting rid of the  near-empty  chroma  channels  won't  be
148              large;  but  the  decoding time for a grayscale JPEG is substan‐
149              tially less than that for a color JPEG.)
150
151       jpegtran also recognizes these switches that control what  to  do  with
152       "extra" markers, such as comment blocks:
153
154       -copy none
155              Copy no extra markers from source file.  This setting suppresses
156              all comments and other excess  baggage  present  in  the  source
157              file.
158
159       -copy comments
160              Copy  only  comment  markers.  This setting copies comments from
161              the source file but discards any other data which is inessential
162              for image display.
163
164       -copy all
165              Copy  all  extra  markers.  This setting preserves miscellaneous
166              markers found in the source file, such as JFIF thumbnails,  Exif
167              data,  and Photoshop settings.  In some files, these extra mark‐
168              ers can be sizable.
169
170       The default behavior is -copy comments.  (Note: in IJG releases v6  and
171       v6a, jpegtran always did the equivalent of -copy none.)
172
173       Additional switches recognized by jpegtran are:
174
175       -maxmemory N
176              Set  limit  for  amount  of  memory  to  use in processing large
177              images.  Value is in thousands of bytes, or millions of bytes if
178              "M"  is  attached  to  the number.  For example, -max 4m selects
179              4000000 bytes.  If more space is needed, temporary files will be
180              used.
181
182       -outfile name
183              Send output image to the named file, not to standard output.
184
185       -verbose
186              Enable  debug printout.  More -v's give more output.  Also, ver‐
187              sion information is printed at startup.
188
189       -debug Same as -verbose.
190

EXAMPLES

192       This example converts a baseline JPEG file to progressive form:
193
194              jpegtran -progressive foo.jpg > fooprog.jpg
195
196       This example rotates an image  90  degrees  clockwise,  discarding  any
197       unrotatable edge pixels:
198
199              jpegtran -rot 90 -trim foo.jpg > foo90.jpg
200

ENVIRONMENT

202       JPEGMEM
203              If  this  environment  variable is set, its value is the default
204              memory limit.  The value  is  specified  as  described  for  the
205              -maxmemory  switch.   JPEGMEM overrides the default value speci‐
206              fied when the program was compiled, and itself is overridden  by
207              an explicit -maxmemory.
208

SEE ALSO

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

AUTHOR

215       Independent JPEG Group
216

BUGS

218       The transform options can't transform odd-size images  perfectly.   Use
219       -trim or -perfect if you don't like the results.
220
221       The  entire  image is read into memory and then written out again, even
222       in cases where this isn't really necessary.  Expect swapping  on  large
223       images, especially when using the more complex transform options.
224
225
226
227                                11 October 2010                    JPEGTRAN(1)
Impressum