usage.txt 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. USAGE instructions for the Independent JPEG Group's JPEG software
  2. =================================================================
  3. This file describes usage of the JPEG conversion programs cjpeg and djpeg,
  4. as well as the utility programs jpegtran, rdjpgcom and wrjpgcom. (See
  5. the other documentation files if you wish to use the JPEG library within
  6. your own programs.)
  7. If you are on a Unix machine you may prefer to read the Unix-style manual
  8. pages in files cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1.
  9. INTRODUCTION
  10. These programs implement JPEG image encoding, decoding, and transcoding.
  11. JPEG (pronounced "jay-peg") is a standardized compression method for
  12. full-color and grayscale images.
  13. GENERAL USAGE
  14. We provide two programs, cjpeg to compress an image file into JPEG format,
  15. and djpeg to decompress a JPEG file back into a conventional image format.
  16. On Unix-like systems, you say:
  17. cjpeg [switches] [imagefile] >jpegfile
  18. or
  19. djpeg [switches] [jpegfile] >imagefile
  20. The programs read the specified input file, or standard input if none is
  21. named. They always write to standard output (with trace/error messages to
  22. standard error). These conventions are handy for piping images between
  23. programs.
  24. On most non-Unix systems, you say:
  25. cjpeg [switches] imagefile jpegfile
  26. or
  27. djpeg [switches] jpegfile imagefile
  28. i.e., both the input and output files are named on the command line. This
  29. style is a little more foolproof, and it loses no functionality if you don't
  30. have pipes. (You can get this style on Unix too, if you prefer, by defining
  31. TWO_FILE_COMMANDLINE when you compile the programs; see install.txt.)
  32. You can also say:
  33. cjpeg [switches] -outfile jpegfile imagefile
  34. or
  35. djpeg [switches] -outfile imagefile jpegfile
  36. This syntax works on all systems, so it is useful for scripts.
  37. The currently supported image file formats are: PPM (PBMPLUS color format),
  38. PGM (PBMPLUS grayscale format), BMP, Targa, and RLE (Utah Raster Toolkit
  39. format). (RLE is supported only if the URT library is available, which it
  40. isn't on most non-Unix systems.) cjpeg recognizes the input image format
  41. automatically, with the exception of some Targa-format files. You have to
  42. tell djpeg which format to generate.
  43. JPEG files are in the standard JFIF file format. There are other,
  44. less widely used JPEG-based file formats, but we don't support them.
  45. All switch names may be abbreviated; for example, -grayscale may be written
  46. -gray or -gr. Most of the "basic" switches can be abbreviated to as little as
  47. one letter. Upper and lower case are equivalent (-BMP is the same as -bmp).
  48. British spellings are also accepted (e.g., -greyscale), though for brevity
  49. these are not mentioned below.
  50. CJPEG DETAILS
  51. The basic command line switches for cjpeg are:
  52. -quality N[,...] Scale quantization tables to adjust image quality.
  53. Quality is 0 (worst) to 100 (best); default is 75.
  54. (See below for more info.)
  55. -grayscale Create monochrome JPEG file from color input.
  56. Be sure to use this switch when compressing a grayscale
  57. BMP file, because cjpeg isn't bright enough to notice
  58. whether a BMP file uses only shades of gray. By
  59. saying -grayscale, you'll get a smaller JPEG file that
  60. takes less time to process.
  61. -rgb Create RGB JPEG file.
  62. Using this switch suppresses the conversion from RGB
  63. colorspace input to the default YCbCr JPEG colorspace.
  64. You can use this switch in combination with the
  65. -block N switch (see below) for lossless JPEG coding.
  66. See also the -rgb1 switch below.
  67. -optimize Perform optimization of entropy encoding parameters.
  68. Without this, default encoding parameters are used.
  69. -optimize usually makes the JPEG file a little smaller,
  70. but cjpeg runs somewhat slower and needs much more
  71. memory. Image quality and speed of decompression are
  72. unaffected by -optimize.
  73. -progressive Create progressive JPEG file (see below).
  74. -scale M/N Scale the output image by a factor M/N. Currently
  75. supported scale factors are M/N with all N from 1 to
  76. 16, where M is the destination DCT size, which is 8 by
  77. default (see -block N switch below).
  78. -targa Input file is Targa format. Targa files that contain
  79. an "identification" field will not be automatically
  80. recognized by cjpeg; for such files you must specify
  81. -targa to make cjpeg treat the input as Targa format.
  82. For most Targa files, you won't need this switch.
  83. The -quality switch lets you trade off compressed file size against quality of
  84. the reconstructed image: the higher the quality setting, the larger the JPEG
  85. file, and the closer the output image will be to the original input. Normally
  86. you want to use the lowest quality setting (smallest file) that decompresses
  87. into something visually indistinguishable from the original image. For this
  88. purpose the quality setting should be between 50 and 95; the default of 75 is
  89. often about right. If you see defects at -quality 75, then go up 5 or 10
  90. counts at a time until you are happy with the output image. (The optimal
  91. setting will vary from one image to another.)
  92. -quality 100 will generate a quantization table of all 1's, minimizing loss
  93. in the quantization step (but there is still information loss in subsampling,
  94. as well as roundoff error). This setting is mainly of interest for
  95. experimental purposes. Quality values above about 95 are NOT recommended for
  96. normal use; the compressed file size goes up dramatically for hardly any gain
  97. in output image quality.
  98. In the other direction, quality values below 50 will produce very small files
  99. of low image quality. Settings around 5 to 10 might be useful in preparing an
  100. index of a large image library, for example. Try -quality 2 (or so) for some
  101. amusing Cubist effects. (Note: quality values below about 25 generate 2-byte
  102. quantization tables, which are considered optional in the JPEG standard.
  103. cjpeg emits a warning message when you give such a quality value, because some
  104. other JPEG programs may be unable to decode the resulting file. Use -baseline
  105. if you need to ensure compatibility at low quality values.)
  106. The -quality option has been extended in IJG version 7 for support of separate
  107. quality settings for luminance and chrominance (or in general, for every
  108. provided quantization table slot). This feature is useful for high-quality
  109. applications which cannot accept the damage of color data by coarse
  110. subsampling settings. You can now easily reduce the color data amount more
  111. smoothly with finer control without separate subsampling. The resulting file
  112. is fully compliant with standard JPEG decoders.
  113. Note that the -quality ratings refer to the quantization table slots, and that
  114. the last value is replicated if there are more q-table slots than parameters.
  115. The default q-table slots are 0 for luminance and 1 for chrominance with
  116. default tables as given in the JPEG standard. This is compatible with the old
  117. behaviour in case that only one parameter is given, which is then used for
  118. both luminance and chrominance (slots 0 and 1). More or custom quantization
  119. tables can be set with -qtables and assigned to components with -qslots
  120. parameter (see the "wizard" switches below).
  121. CAUTION: You must explicitly add -sample 1x1 for efficient separate color
  122. quality selection, since the default value used by library is 2x2!
  123. The -progressive switch creates a "progressive JPEG" file. In this type of
  124. JPEG file, the data is stored in multiple scans of increasing quality. If the
  125. file is being transmitted over a slow communications link, the decoder can use
  126. the first scan to display a low-quality image very quickly, and can then
  127. improve the display with each subsequent scan. The final image is exactly
  128. equivalent to a standard JPEG file of the same quality setting, and the total
  129. file size is about the same --- often a little smaller.
  130. Switches for advanced users:
  131. -arithmetic Use arithmetic coding.
  132. CAUTION: arithmetic coded JPEG is not yet widely
  133. implemented, so many decoders will be unable to
  134. view an arithmetic coded JPEG file at all.
  135. -block N Set DCT block size. All N from 1 to 16 are possible.
  136. Default is 8 (baseline format).
  137. Larger values produce higher compression,
  138. smaller values produce higher quality
  139. (exact DCT stage possible with 1 or 2; with the
  140. default quality of 75 and default Luminance qtable
  141. the DCT+Quantization stage is lossless for N=1).
  142. CAUTION: An implementation of the JPEG SmartScale
  143. extension is required for this feature. SmartScale
  144. enabled JPEG is not yet widely implemented, so many
  145. decoders will be unable to view a SmartScale extended
  146. JPEG file at all.
  147. -rgb1 Create RGB JPEG file with reversible color transform.
  148. Works like the -rgb switch (see above) and inserts a
  149. simple reversible color transform into the processing
  150. which significantly improves the compression.
  151. Use this switch in combination with the -block N
  152. switch (see above) for lossless JPEG coding.
  153. CAUTION: A decoder with inverse color transform
  154. support is required for this feature. Reversible
  155. color transform support is not yet widely implemented,
  156. so many decoders will be unable to view a reversible
  157. color transformed JPEG file at all.
  158. -bgycc Create big gamut YCC JPEG file.
  159. In this type of encoding the color difference
  160. components are quantized further by a factor of 2
  161. compared to the normal Cb/Cr values, thus creating
  162. space to allow larger color values with higher
  163. saturation than the normal gamut limits to be encoded.
  164. In order to compensate for the loss of color fidelity
  165. compared to a normal YCC encoded file, the color
  166. quantization tables can be adjusted accordingly.
  167. For example, cjpeg -bgycc -quality 80,90 will give
  168. similar results as cjpeg -quality 80.
  169. CAUTION: For correct decompression a decoder with big
  170. gamut YCC support (JFIF version 2) is required.
  171. An old decoder may or may not display a big gamut YCC
  172. encoded JPEG file, depending on JFIF version check
  173. and corresponding warning/error configuration.
  174. In case of a granted decompression the old decoder
  175. will display the image with half saturated colors.
  176. -dct int Use integer DCT method (default).
  177. -dct fast Use fast integer DCT (less accurate).
  178. -dct float Use floating-point DCT method.
  179. The float method is very slightly more accurate than
  180. the int method, but is much slower unless your machine
  181. has very fast floating-point hardware. Also note that
  182. results of the floating-point method may vary slightly
  183. across machines, while the integer methods should give
  184. the same results everywhere. The fast integer method
  185. is much less accurate than the other two.
  186. -nosmooth Don't use high-quality downsampling.
  187. -restart N Emit a JPEG restart marker every N MCU rows, or every
  188. N MCU blocks if "B" is attached to the number.
  189. -restart 0 (the default) means no restart markers.
  190. -smooth N Smooth the input image to eliminate dithering noise.
  191. N, ranging from 1 to 100, indicates the strength of
  192. smoothing. 0 (the default) means no smoothing.
  193. -maxmemory N Set limit for amount of memory to use in processing
  194. large images. Value is in thousands of bytes, or
  195. millions of bytes if "M" is attached to the number.
  196. For example, -max 4m selects 4000000 bytes. If more
  197. space is needed, temporary files will be used.
  198. -verbose Enable debug printout. More -v's give more printout.
  199. or -debug Also, version information is printed at startup.
  200. The -restart option inserts extra markers that allow a JPEG decoder to
  201. resynchronize after a transmission error. Without restart markers, any damage
  202. to a compressed file will usually ruin the image from the point of the error
  203. to the end of the image; with restart markers, the damage is usually confined
  204. to the portion of the image up to the next restart marker. Of course, the
  205. restart markers occupy extra space. We recommend -restart 1 for images that
  206. will be transmitted across unreliable networks such as Usenet.
  207. The -smooth option filters the input to eliminate fine-scale noise. This is
  208. often useful when converting dithered images to JPEG: a moderate smoothing
  209. factor of 10 to 50 gets rid of dithering patterns in the input file, resulting
  210. in a smaller JPEG file and a better-looking image. Too large a smoothing
  211. factor will visibly blur the image, however.
  212. Switches for wizards:
  213. -baseline Force baseline-compatible quantization tables to be
  214. generated. This clamps quantization values to 8 bits
  215. even at low quality settings. (This switch is poorly
  216. named, since it does not ensure that the output is
  217. actually baseline JPEG. For example, you can use
  218. -baseline and -progressive together.)
  219. -qtables file Use the quantization tables given in the specified
  220. text file.
  221. -qslots N[,...] Select which quantization table to use for each color
  222. component.
  223. -sample HxV[,...] Set JPEG sampling factors for each color component.
  224. -scans file Use the scan script given in the specified text file.
  225. The "wizard" switches are intended for experimentation with JPEG. If you
  226. don't know what you are doing, DON'T USE THEM. These switches are documented
  227. further in the file wizard.txt.
  228. DJPEG DETAILS
  229. The basic command line switches for djpeg are:
  230. -colors N Reduce image to at most N colors. This reduces the
  231. or -quantize N number of colors used in the output image, so that it
  232. can be displayed on a colormapped display or stored in
  233. a colormapped file format. For example, if you have
  234. an 8-bit display, you'd need to reduce to 256 or fewer
  235. colors. (-colors is the recommended name, -quantize
  236. is provided only for backwards compatibility.)
  237. -fast Select recommended processing options for fast, low
  238. quality output. (The default options are chosen for
  239. highest quality output.) Currently, this is equivalent
  240. to "-dct fast -nosmooth -onepass -dither ordered".
  241. -grayscale Force grayscale output even if JPEG file is color.
  242. Useful for viewing on monochrome displays; also,
  243. djpeg runs noticeably faster in this mode.
  244. -rgb Force RGB output even if JPEG file is grayscale.
  245. This is provided to support applications that don't
  246. want to cope with grayscale as a separate case.
  247. -scale M/N Scale the output image by a factor M/N. Currently
  248. supported scale factors are M/N with all M from 1 to
  249. 16, where N is the source DCT size, which is 8 for
  250. baseline JPEG. If the /N part is omitted, then M
  251. specifies the DCT scaled size to be applied on the
  252. given input. For baseline JPEG this is equivalent to
  253. M/8 scaling, since the source DCT size for baseline
  254. JPEG is 8. Scaling is handy if the image is larger
  255. than your screen; also, djpeg runs much faster when
  256. scaling down the output.
  257. -bmp Select BMP output format (Windows flavor). 8-bit
  258. colormapped format is emitted if -colors or -grayscale
  259. is specified, or if the JPEG file is grayscale;
  260. otherwise, 24-bit full-color format is emitted.
  261. -gif Select GIF output format. Since GIF does not support
  262. more than 256 colors, -colors 256 is assumed (unless
  263. you specify a smaller number of colors). If you
  264. specify -fast, the default number of colors is 216.
  265. -os2 Select BMP output format (OS/2 1.x flavor). 8-bit
  266. colormapped format is emitted if -colors or -grayscale
  267. is specified, or if the JPEG file is grayscale;
  268. otherwise, 24-bit full-color format is emitted.
  269. -pnm Select PBMPLUS (PPM/PGM) output format (this is the
  270. default format). PGM is emitted if the JPEG file is
  271. grayscale or if -grayscale is specified; otherwise
  272. PPM is emitted.
  273. -rle Select RLE output format. (Requires URT library.)
  274. -targa Select Targa output format. Grayscale format is
  275. emitted if the JPEG file is grayscale or if
  276. -grayscale is specified; otherwise, colormapped format
  277. is emitted if -colors is specified; otherwise, 24-bit
  278. full-color format is emitted.
  279. Switches for advanced users:
  280. -dct int Use integer DCT method (default).
  281. -dct fast Use fast integer DCT (less accurate).
  282. -dct float Use floating-point DCT method.
  283. The float method is very slightly more accurate than
  284. the int method, but is much slower unless your machine
  285. has very fast floating-point hardware. Also note that
  286. results of the floating-point method may vary slightly
  287. across machines, while the integer methods should give
  288. the same results everywhere. The fast integer method
  289. is much less accurate than the other two.
  290. -dither fs Use Floyd-Steinberg dithering in color quantization.
  291. -dither ordered Use ordered dithering in color quantization.
  292. -dither none Do not use dithering in color quantization.
  293. By default, Floyd-Steinberg dithering is applied when
  294. quantizing colors; this is slow but usually produces
  295. the best results. Ordered dither is a compromise
  296. between speed and quality; no dithering is fast but
  297. usually looks awful. Note that these switches have
  298. no effect unless color quantization is being done.
  299. Ordered dither is only available in -onepass mode.
  300. -map FILE Quantize to the colors used in the specified image
  301. file. This is useful for producing multiple files
  302. with identical color maps, or for forcing a predefined
  303. set of colors to be used. The FILE must be a GIF
  304. or PPM file. This option overrides -colors and
  305. -onepass.
  306. -nosmooth Don't use high-quality upsampling.
  307. -onepass Use one-pass instead of two-pass color quantization.
  308. The one-pass method is faster and needs less memory,
  309. but it produces a lower-quality image. -onepass is
  310. ignored unless you also say -colors N. Also,
  311. the one-pass method is always used for grayscale
  312. output (the two-pass method is no improvement then).
  313. -maxmemory N Set limit for amount of memory to use in processing
  314. large images. Value is in thousands of bytes, or
  315. millions of bytes if "M" is attached to the number.
  316. For example, -max 4m selects 4000000 bytes. If more
  317. space is needed, temporary files will be used.
  318. -verbose Enable debug printout. More -v's give more printout.
  319. or -debug Also, version information is printed at startup.
  320. HINTS FOR CJPEG
  321. Color GIF files are not the ideal input for JPEG; JPEG is really intended for
  322. compressing full-color (24-bit) images. In particular, don't try to convert
  323. cartoons, line drawings, and other images that have only a few distinct
  324. colors. GIF works great on these, JPEG does not. If you want to convert a
  325. GIF to JPEG, you should experiment with cjpeg's -quality and -smooth options
  326. to get a satisfactory conversion. -smooth 10 or so is often helpful.
  327. Avoid running an image through a series of JPEG compression/decompression
  328. cycles. Image quality loss will accumulate; after ten or so cycles the image
  329. may be noticeably worse than it was after one cycle. It's best to use a
  330. lossless format while manipulating an image, then convert to JPEG format when
  331. you are ready to file the image away.
  332. The -optimize option to cjpeg is worth using when you are making a "final"
  333. version for posting or archiving. It's also a win when you are using low
  334. quality settings to make very small JPEG files; the percentage improvement
  335. is often a lot more than it is on larger files. (At present, -optimize
  336. mode is always selected when generating progressive JPEG files.)
  337. GIF input files are no longer supported, to avoid the Unisys LZW patent
  338. (now expired).
  339. (Conversion of GIF files to JPEG is usually a bad idea anyway.)
  340. HINTS FOR DJPEG
  341. To get a quick preview of an image, use the -grayscale and/or -scale switches.
  342. "-grayscale -scale 1/8" is the fastest case.
  343. Several options are available that trade off image quality to gain speed.
  344. "-fast" turns on the recommended settings.
  345. "-dct fast" and/or "-nosmooth" gain speed at a small sacrifice in quality.
  346. When producing a color-quantized image, "-onepass -dither ordered" is fast but
  347. much lower quality than the default behavior. "-dither none" may give
  348. acceptable results in two-pass mode, but is seldom tolerable in one-pass mode.
  349. If you are fortunate enough to have very fast floating point hardware,
  350. "-dct float" may be even faster than "-dct fast". But on most machines
  351. "-dct float" is slower than "-dct int"; in this case it is not worth using,
  352. because its theoretical accuracy advantage is too small to be significant
  353. in practice.
  354. Two-pass color quantization requires a good deal of memory; on MS-DOS machines
  355. it may run out of memory even with -maxmemory 0. In that case you can still
  356. decompress, with some loss of image quality, by specifying -onepass for
  357. one-pass quantization.
  358. To avoid the Unisys LZW patent (now expired), djpeg produces uncompressed GIF
  359. files. These are larger than they should be, but are readable by standard GIF
  360. decoders.
  361. HINTS FOR BOTH PROGRAMS
  362. If more space is needed than will fit in the available main memory (as
  363. determined by -maxmemory), temporary files will be used. (MS-DOS versions
  364. will try to get extended or expanded memory first.) The temporary files are
  365. often rather large: in typical cases they occupy three bytes per pixel, for
  366. example 3*800*600 = 1.44Mb for an 800x600 image. If you don't have enough
  367. free disk space, leave out -progressive and -optimize (for cjpeg) or specify
  368. -onepass (for djpeg).
  369. On MS-DOS, the temporary files are created in the directory named by the TMP
  370. or TEMP environment variable, or in the current directory if neither of those
  371. exist. Amiga implementations put the temp files in the directory named by
  372. JPEGTMP:, so be sure to assign JPEGTMP: to a disk partition with adequate free
  373. space.
  374. The default memory usage limit (-maxmemory) is set when the software is
  375. compiled. If you get an "insufficient memory" error, try specifying a smaller
  376. -maxmemory value, even -maxmemory 0 to use the absolute minimum space. You
  377. may want to recompile with a smaller default value if this happens often.
  378. On machines that have "environment" variables, you can define the environment
  379. variable JPEGMEM to set the default memory limit. The value is specified as
  380. described for the -maxmemory switch. JPEGMEM overrides the default value
  381. specified when the program was compiled, and itself is overridden by an
  382. explicit -maxmemory switch.
  383. On MS-DOS machines, -maxmemory is the amount of main (conventional) memory to
  384. use. (Extended or expanded memory is also used if available.) Most
  385. DOS-specific versions of this software do their own memory space estimation
  386. and do not need you to specify -maxmemory.
  387. JPEGTRAN
  388. jpegtran performs various useful transformations of JPEG files.
  389. It can translate the coded representation from one variant of JPEG to another,
  390. for example from baseline JPEG to progressive JPEG or vice versa. It can also
  391. perform some rearrangements of the image data, for example turning an image
  392. from landscape to portrait format by rotation. For EXIF files and JPEG files
  393. containing Exif data, you may prefer to use exiftran instead.
  394. jpegtran works by rearranging the compressed data (DCT coefficients), without
  395. ever fully decoding the image. Therefore, its transformations are lossless:
  396. there is no image degradation at all, which would not be true if you used
  397. djpeg followed by cjpeg to accomplish the same conversion. But by the same
  398. token, jpegtran cannot perform lossy operations such as changing the image
  399. quality. However, while the image data is losslessly transformed, metadata
  400. can be removed. See the -copy option for specifics.
  401. jpegtran uses a command line syntax similar to cjpeg or djpeg.
  402. On Unix-like systems, you say:
  403. jpegtran [switches] [inputfile] >outputfile
  404. On most non-Unix systems, you say:
  405. jpegtran [switches] inputfile outputfile
  406. where both the input and output files are JPEG files.
  407. To specify the coded JPEG representation used in the output file,
  408. jpegtran accepts a subset of the switches recognized by cjpeg:
  409. -optimize Perform optimization of entropy encoding parameters.
  410. -progressive Create progressive JPEG file.
  411. -arithmetic Use arithmetic coding.
  412. -restart N Emit a JPEG restart marker every N MCU rows, or every
  413. N MCU blocks if "B" is attached to the number.
  414. -scans file Use the scan script given in the specified text file.
  415. See the previous discussion of cjpeg for more details about these switches.
  416. If you specify none of these switches, you get a plain baseline-JPEG output
  417. file. The quality setting and so forth are determined by the input file.
  418. The image can be losslessly transformed by giving one of these switches:
  419. -flip horizontal Mirror image horizontally (left-right).
  420. -flip vertical Mirror image vertically (top-bottom).
  421. -rotate 90 Rotate image 90 degrees clockwise.
  422. -rotate 180 Rotate image 180 degrees.
  423. -rotate 270 Rotate image 270 degrees clockwise (or 90 ccw).
  424. -transpose Transpose image (across UL-to-LR axis).
  425. -transverse Transverse transpose (across UR-to-LL axis).
  426. The transpose transformation has no restrictions regarding image dimensions.
  427. The other transformations operate rather oddly if the image dimensions are not
  428. a multiple of the iMCU size (usually 8 or 16 pixels), because they can only
  429. transform complete blocks of DCT coefficient data in the desired way.
  430. jpegtran's default behavior when transforming an odd-size image is designed
  431. to preserve exact reversibility and mathematical consistency of the
  432. transformation set. As stated, transpose is able to flip the entire image
  433. area. Horizontal mirroring leaves any partial iMCU column at the right edge
  434. untouched, but is able to flip all rows of the image. Similarly, vertical
  435. mirroring leaves any partial iMCU row at the bottom edge untouched, but is
  436. able to flip all columns. The other transforms can be built up as sequences
  437. of transpose and flip operations; for consistency, their actions on edge
  438. pixels are defined to be the same as the end result of the corresponding
  439. transpose-and-flip sequence.
  440. For practical use, you may prefer to discard any untransformable edge pixels
  441. rather than having a strange-looking strip along the right and/or bottom edges
  442. of a transformed image. To do this, add the -trim switch:
  443. -trim Drop non-transformable edge blocks.
  444. Obviously, a transformation with -trim is not reversible, so strictly speaking
  445. jpegtran with this switch is not lossless. Also, the expected mathematical
  446. equivalences between the transformations no longer hold. For example,
  447. "-rot 270 -trim" trims only the bottom edge, but "-rot 90 -trim" followed by
  448. "-rot 180 -trim" trims both edges.
  449. If you are only interested in perfect transformation, add the -perfect switch:
  450. -perfect Fails with an error if the transformation is not
  451. perfect.
  452. For example you may want to do
  453. jpegtran -rot 90 -perfect foo.jpg || djpeg foo.jpg | pnmflip -r90 | cjpeg
  454. to do a perfect rotation if available or an approximated one if not.
  455. We also offer a lossless-crop option, which discards data outside a given
  456. image region but losslessly preserves what is inside. Like the rotate and
  457. flip transforms, lossless crop is restricted by the current JPEG format: the
  458. upper left corner of the selected region must fall on an iMCU boundary. If
  459. this does not hold for the given crop parameters, we silently move the upper
  460. left corner up and/or left to make it so, simultaneously increasing the
  461. region dimensions to keep the lower right crop corner unchanged. (Thus, the
  462. output image covers at least the requested region, but may cover more.)
  463. The adjustment of the region dimensions may be optionally disabled by
  464. attaching an 'f' character ("force") to the width or height number.
  465. The image can be losslessly cropped by giving the switch:
  466. -crop WxH+X+Y Crop to a rectangular subarea of width W, height H
  467. starting at point X,Y.
  468. A complementary lossless-wipe option is provided to discard (gray out) data
  469. inside a given image region while losslessly preserving what is outside:
  470. -wipe WxH+X+Y Wipe (gray out) a rectangular subarea of
  471. width W, height H starting at point X,Y.
  472. Other not-strictly-lossless transformation switches are:
  473. -grayscale Force grayscale output.
  474. This option discards the chrominance channels if the input image is YCbCr
  475. (ie, a standard color JPEG), resulting in a grayscale JPEG file. The
  476. luminance channel is preserved exactly, so this is a better method of reducing
  477. to grayscale than decompression, conversion, and recompression. This switch
  478. is particularly handy for fixing a monochrome picture that was mistakenly
  479. encoded as a color JPEG. (In such a case, the space savings from getting rid
  480. of the near-empty chroma channels won't be large; but the decoding time for
  481. a grayscale JPEG is substantially less than that for a color JPEG.)
  482. -scale M/N Scale the output image by a factor M/N.
  483. Currently supported scale factors are M/N with all M from 1 to 16, where N is
  484. the source DCT size, which is 8 for baseline JPEG. If the /N part is omitted,
  485. then M specifies the DCT scaled size to be applied on the given input. For
  486. baseline JPEG this is equivalent to M/8 scaling, since the source DCT size
  487. for baseline JPEG is 8. CAUTION: An implementation of the JPEG SmartScale
  488. extension is required for this feature. SmartScale enabled JPEG is not yet
  489. widely implemented, so many decoders will be unable to view a SmartScale
  490. extended JPEG file at all.
  491. jpegtran also recognizes these switches that control what to do with "extra"
  492. markers, such as comment blocks:
  493. -copy none Copy no extra markers from source file.
  494. This setting suppresses all comments
  495. and other metadata in the source file.
  496. -copy comments Copy only comment markers.
  497. This setting copies comments from the source file,
  498. but discards any other metadata.
  499. -copy all Copy all extra markers. This setting preserves
  500. metadata found in the source file, such as JFIF
  501. thumbnails, Exif data, and Photoshop settings.
  502. In some files these extra markers can be sizable.
  503. Note that this option will copy thumbnails as-is;
  504. they will not be transformed.
  505. The default behavior is -copy comments. (Note: in IJG releases v6 and v6a,
  506. jpegtran always did the equivalent of -copy none.)
  507. Additional switches recognized by jpegtran are:
  508. -outfile filename
  509. -maxmemory N
  510. -verbose
  511. -debug
  512. These work the same as in cjpeg or djpeg.
  513. THE COMMENT UTILITIES
  514. The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file.
  515. Although the standard doesn't actually define what COM blocks are for, they
  516. are widely used to hold user-supplied text strings. This lets you add
  517. annotations, titles, index terms, etc to your JPEG files, and later retrieve
  518. them as text. COM blocks do not interfere with the image stored in the JPEG
  519. file. The maximum size of a COM block is 64K, but you can have as many of
  520. them as you like in one JPEG file.
  521. We provide two utility programs to display COM block contents and add COM
  522. blocks to a JPEG file.
  523. rdjpgcom searches a JPEG file and prints the contents of any COM blocks on
  524. standard output. The command line syntax is
  525. rdjpgcom [-raw] [-verbose] [inputfilename]
  526. The switch "-raw" (or just "-r") causes rdjpgcom to also output non-printable
  527. characters in comments, which are normally escaped for security reasons.
  528. The switch "-verbose" (or just "-v") causes rdjpgcom to also display the JPEG
  529. image dimensions. If you omit the input file name from the command line,
  530. the JPEG file is read from standard input. (This may not work on some
  531. operating systems, if binary data can't be read from stdin.)
  532. wrjpgcom adds a COM block, containing text you provide, to a JPEG file.
  533. Ordinarily, the COM block is added after any existing COM blocks, but you
  534. can delete the old COM blocks if you wish. wrjpgcom produces a new JPEG
  535. file; it does not modify the input file. DO NOT try to overwrite the input
  536. file by directing wrjpgcom's output back into it; on most systems this will
  537. just destroy your file.
  538. The command line syntax for wrjpgcom is similar to cjpeg's. On Unix-like
  539. systems, it is
  540. wrjpgcom [switches] [inputfilename]
  541. The output file is written to standard output. The input file comes from
  542. the named file, or from standard input if no input file is named.
  543. On most non-Unix systems, the syntax is
  544. wrjpgcom [switches] inputfilename outputfilename
  545. where both input and output file names must be given explicitly.
  546. wrjpgcom understands three switches:
  547. -replace Delete any existing COM blocks from the file.
  548. -comment "Comment text" Supply new COM text on command line.
  549. -cfile name Read text for new COM block from named file.
  550. (Switch names can be abbreviated.) If you have only one line of comment text
  551. to add, you can provide it on the command line with -comment. The comment
  552. text must be surrounded with quotes so that it is treated as a single
  553. argument. Longer comments can be read from a text file.
  554. If you give neither -comment nor -cfile, then wrjpgcom will read the comment
  555. text from standard input. (In this case an input image file name MUST be
  556. supplied, so that the source JPEG file comes from somewhere else.) You can
  557. enter multiple lines, up to 64KB worth. Type an end-of-file indicator
  558. (usually control-D or control-Z) to terminate the comment text entry.
  559. wrjpgcom will not add a COM block if the provided comment string is empty.
  560. Therefore -replace -comment "" can be used to delete all COM blocks from a
  561. file.
  562. These utility programs do not depend on the IJG JPEG library. In
  563. particular, the source code for rdjpgcom is intended as an illustration of
  564. the minimum amount of code required to parse a JPEG file header correctly.