jpegtran.1 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. .TH JPEGTRAN 1 "28 March 2009"
  2. .SH NAME
  3. jpegtran \- lossless transformation of JPEG files
  4. .SH SYNOPSIS
  5. .B jpegtran
  6. [
  7. .I options
  8. ]
  9. [
  10. .I filename
  11. ]
  12. .LP
  13. .SH DESCRIPTION
  14. .LP
  15. .B jpegtran
  16. performs various useful transformations of JPEG files.
  17. It can translate the coded representation from one variant of JPEG to another,
  18. for example from baseline JPEG to progressive JPEG or vice versa. It can also
  19. perform some rearrangements of the image data, for example turning an image
  20. from landscape to portrait format by rotation.
  21. .PP
  22. .B jpegtran
  23. works by rearranging the compressed data (DCT coefficients), without
  24. ever fully decoding the image. Therefore, its transformations are lossless:
  25. there is no image degradation at all, which would not be true if you used
  26. .B djpeg
  27. followed by
  28. .B cjpeg
  29. to accomplish the same conversion. But by the same token,
  30. .B jpegtran
  31. cannot perform lossy operations such as changing the image quality.
  32. .PP
  33. .B jpegtran
  34. reads the named JPEG/JFIF file, or the standard input if no file is
  35. named, and produces a JPEG/JFIF file on the standard output.
  36. .SH OPTIONS
  37. All switch names may be abbreviated; for example,
  38. .B \-optimize
  39. may be written
  40. .B \-opt
  41. or
  42. .BR \-o .
  43. Upper and lower case are equivalent.
  44. British spellings are also accepted (e.g.,
  45. .BR \-optimise ),
  46. though for brevity these are not mentioned below.
  47. .PP
  48. To specify the coded JPEG representation used in the output file,
  49. .B jpegtran
  50. accepts a subset of the switches recognized by
  51. .BR cjpeg :
  52. .TP
  53. .B \-optimize
  54. Perform optimization of entropy encoding parameters.
  55. .TP
  56. .B \-progressive
  57. Create progressive JPEG file.
  58. .TP
  59. .BI \-restart " N"
  60. Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is
  61. attached to the number.
  62. .TP
  63. .B \-arithmetic
  64. Use arithmetic coding.
  65. .TP
  66. .BI \-scans " file"
  67. Use the scan script given in the specified text file.
  68. .PP
  69. See
  70. .BR cjpeg (1)
  71. for more details about these switches.
  72. If you specify none of these switches, you get a plain baseline-JPEG output
  73. file. The quality setting and so forth are determined by the input file.
  74. .PP
  75. The image can be losslessly transformed by giving one of these switches:
  76. .TP
  77. .B \-flip horizontal
  78. Mirror image horizontally (left-right).
  79. .TP
  80. .B \-flip vertical
  81. Mirror image vertically (top-bottom).
  82. .TP
  83. .B \-rotate 90
  84. Rotate image 90 degrees clockwise.
  85. .TP
  86. .B \-rotate 180
  87. Rotate image 180 degrees.
  88. .TP
  89. .B \-rotate 270
  90. Rotate image 270 degrees clockwise (or 90 ccw).
  91. .TP
  92. .B \-transpose
  93. Transpose image (across UL-to-LR axis).
  94. .TP
  95. .B \-transverse
  96. Transverse transpose (across UR-to-LL axis).
  97. .IP
  98. The transpose transformation has no restrictions regarding image dimensions.
  99. The other transformations operate rather oddly if the image dimensions are not
  100. a multiple of the iMCU size (usually 8 or 16 pixels), because they can only
  101. transform complete blocks of DCT coefficient data in the desired way.
  102. .IP
  103. .BR jpegtran 's
  104. default behavior when transforming an odd-size image is designed
  105. to preserve exact reversibility and mathematical consistency of the
  106. transformation set. As stated, transpose is able to flip the entire image
  107. area. Horizontal mirroring leaves any partial iMCU column at the right edge
  108. untouched, but is able to flip all rows of the image. Similarly, vertical
  109. mirroring leaves any partial iMCU row at the bottom edge untouched, but is
  110. able to flip all columns. The other transforms can be built up as sequences
  111. of transpose and flip operations; for consistency, their actions on edge
  112. pixels are defined to be the same as the end result of the corresponding
  113. transpose-and-flip sequence.
  114. .IP
  115. For practical use, you may prefer to discard any untransformable edge pixels
  116. rather than having a strange-looking strip along the right and/or bottom edges
  117. of a transformed image. To do this, add the
  118. .B \-trim
  119. switch:
  120. .TP
  121. .B \-trim
  122. Drop non-transformable edge blocks.
  123. .IP
  124. Obviously, a transformation with
  125. .B \-trim
  126. is not reversible, so strictly speaking
  127. .B jpegtran
  128. with this switch is not lossless. Also, the expected mathematical
  129. equivalences between the transformations no longer hold. For example,
  130. .B \-rot 270 -trim
  131. trims only the bottom edge, but
  132. .B \-rot 90 -trim
  133. followed by
  134. .B \-rot 180 -trim
  135. trims both edges.
  136. .IP
  137. If you are only interested in perfect transformation, add the
  138. .B \-perfect
  139. switch:
  140. .TP
  141. .B \-perfect
  142. Fails with an error if the transformation is not perfect.
  143. .IP
  144. For example you may want to do
  145. .IP
  146. .B (jpegtran \-rot 90 -perfect
  147. .I foo.jpg
  148. .B || djpeg
  149. .I foo.jpg
  150. .B | pnmflip \-r90 | cjpeg)
  151. .IP
  152. to do a perfect rotation if available or an approximated one if not.
  153. .PP
  154. We also offer a lossless-crop option, which discards data outside a given
  155. image region but losslessly preserves what is inside. Like the rotate and
  156. flip transforms, lossless crop is restricted by the current JPEG format: the
  157. upper left corner of the selected region must fall on an iMCU boundary. If
  158. this does not hold for the given crop parameters, we silently move the upper
  159. left corner up and/or left to make it so, simultaneously increasing the region
  160. dimensions to keep the lower right crop corner unchanged. (Thus, the output
  161. image covers at least the requested region, but may cover more.)
  162. The image can be losslessly cropped by giving the switch:
  163. .TP
  164. .B \-crop WxH+X+Y
  165. Crop to a rectangular subarea of width W, height H starting at point X,Y.
  166. .PP
  167. Another not-strictly-lossless transformation switch is:
  168. .TP
  169. .B \-grayscale
  170. Force grayscale output.
  171. .IP
  172. This option discards the chrominance channels if the input image is YCbCr
  173. (ie, a standard color JPEG), resulting in a grayscale JPEG file. The
  174. luminance channel is preserved exactly, so this is a better method of reducing
  175. to grayscale than decompression, conversion, and recompression. This switch
  176. is particularly handy for fixing a monochrome picture that was mistakenly
  177. encoded as a color JPEG. (In such a case, the space savings from getting rid
  178. of the near-empty chroma channels won't be large; but the decoding time for
  179. a grayscale JPEG is substantially less than that for a color JPEG.)
  180. .PP
  181. .B jpegtran
  182. also recognizes these switches that control what to do with "extra" markers,
  183. such as comment blocks:
  184. .TP
  185. .B \-copy none
  186. Copy no extra markers from source file. This setting suppresses all
  187. comments and other excess baggage present in the source file.
  188. .TP
  189. .B \-copy comments
  190. Copy only comment markers. This setting copies comments from the source file,
  191. but discards any other inessential (for image display) data.
  192. .TP
  193. .B \-copy all
  194. Copy all extra markers. This setting preserves miscellaneous markers
  195. found in the source file, such as JFIF thumbnails, Exif data, and Photoshop
  196. settings. In some files these extra markers can be sizable.
  197. .IP
  198. The default behavior is
  199. .BR "\-copy comments" .
  200. (Note: in IJG releases v6 and v6a,
  201. .B jpegtran
  202. always did the equivalent of
  203. .BR "\-copy none" .)
  204. .PP
  205. Additional switches recognized by jpegtran are:
  206. .TP
  207. .BI \-maxmemory " N"
  208. Set limit for amount of memory to use in processing large images. Value is
  209. in thousands of bytes, or millions of bytes if "M" is attached to the
  210. number. For example,
  211. .B \-max 4m
  212. selects 4000000 bytes. If more space is needed, temporary files will be used.
  213. .TP
  214. .BI \-outfile " name"
  215. Send output image to the named file, not to standard output.
  216. .TP
  217. .B \-verbose
  218. Enable debug printout. More
  219. .BR \-v 's
  220. give more output. Also, version information is printed at startup.
  221. .TP
  222. .B \-debug
  223. Same as
  224. .BR \-verbose .
  225. .SH EXAMPLES
  226. .LP
  227. This example converts a baseline JPEG file to progressive form:
  228. .IP
  229. .B jpegtran \-progressive
  230. .I foo.jpg
  231. .B >
  232. .I fooprog.jpg
  233. .PP
  234. This example rotates an image 90 degrees clockwise, discarding any
  235. unrotatable edge pixels:
  236. .IP
  237. .B jpegtran \-rot 90 -trim
  238. .I foo.jpg
  239. .B >
  240. .I foo90.jpg
  241. .SH ENVIRONMENT
  242. .TP
  243. .B JPEGMEM
  244. If this environment variable is set, its value is the default memory limit.
  245. The value is specified as described for the
  246. .B \-maxmemory
  247. switch.
  248. .B JPEGMEM
  249. overrides the default value specified when the program was compiled, and
  250. itself is overridden by an explicit
  251. .BR \-maxmemory .
  252. .SH SEE ALSO
  253. .BR cjpeg (1),
  254. .BR djpeg (1),
  255. .BR rdjpgcom (1),
  256. .BR wrjpgcom (1)
  257. .br
  258. Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
  259. Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
  260. .SH AUTHOR
  261. Independent JPEG Group
  262. .SH BUGS
  263. The transform options can't transform odd-size images perfectly. Use
  264. .B \-trim
  265. or
  266. .B \-perfect
  267. if you don't like the results.
  268. .PP
  269. The entire image is read into memory and then written out again, even in
  270. cases where this isn't really necessary. Expect swapping on large images,
  271. especially when using the more complex transform options.