home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Aktief 1995 #6 / CDA_6.iso / shell / utils / jpeg6386.arj / USAGE.DOC < prev    next >
Text File  |  1995-08-09  |  22KB  |  455 lines

  1. USAGE instructions for the Independent JPEG Group's JPEG software
  2. =================================================================
  3.  
  4. INTRODUCTION
  5.  
  6. These programs implement JPEG image compression and decompression.  JPEG
  7. (pronounced "jay-peg") is a standardized compression method for full-color
  8. and gray-scale images.  JPEG is designed to handle "real-world" scenes,
  9. for example scanned photographs.  Cartoons, line drawings, and other
  10. non-realistic images are not JPEG's strong suit; on that sort of material
  11. you may get poor image quality and/or little compression.
  12.  
  13. JPEG is lossy, meaning that the output image is not necessarily identical to
  14. the input image.  Hence you should not use JPEG if you have to have identical
  15. output bits.  However, on typical real-world images, very good compression
  16. levels can be obtained with no visible change, and amazingly high compression
  17. is possible if you can tolerate a low-quality image.  You can trade off image
  18. quality against file size by adjusting the compressor's "quality" setting.
  19.  
  20.  
  21. GENERAL USAGE
  22.  
  23. We provide two programs, cjpeg to compress an image file into JPEG format,
  24. and djpeg to decompress a JPEG file back into a conventional image format.
  25.  
  26. The basic command line is:
  27.     cjpeg [switches] list of image files
  28. or
  29.     djpeg [switches] list of jpeg files
  30.  
  31. Each file named is compressed or decompressed.  The input file(s) are not
  32. modified; the output data is written to files which have the same names
  33. except for extension.  cjpeg always uses ".jpg" for the output file name's
  34. extension; djpeg uses one of ".bmp", ".gif", ".ppm", ".rle", or ".tga",
  35. depending on what output format is selected by the switches.
  36.  
  37. For example, to convert xxx.gif to xxx.jpg and yyy.ppm to yyy.jpg, say:
  38.     cjpeg xxx.gif yyy.ppm
  39.  
  40. On most systems you can use standard wildcards to specify the list of input
  41. files; for example, on DOS "djpeg *.jpg" decompresses all the JPEG files in
  42. the current directory.
  43.  
  44. If an intended output file already exists, you'll be asked whether or not to
  45. overwrite it.  If you say no, the program skips that input file and goes on
  46. to the next one.
  47.  
  48. You can intermix switches and file names; for example
  49.     djpeg -gif file1.jpg -targa file2.jpg
  50. decompresses file1.jpg into GIF format (file1.gif) and file2.jpg into Targa
  51. format (file2.tga).  Only switches to the left of a given file name affect
  52. processing of that file; when there are conflicting switches, the rightmost
  53. one takes precedence.
  54.  
  55. You can override the program's choice of output file name by using the
  56. -outfile switch, as in
  57.     cjpeg -outfile output.jpg input.ppm
  58. -outfile only affects the first input file name to its right.
  59.  
  60. The currently supported image file formats are: PPM (PBMPLUS color format),
  61. PGM (PBMPLUS gray-scale format), BMP, GIF, Targa, and RLE (Utah Raster
  62. Toolkit format).  (RLE is supported only if the URT library is available,
  63. which it isn't on most non-Unix systems.)  cjpeg recognizes the input image
  64. format automatically, with the exception of some Targa-format files.  You
  65. have to tell djpeg which format to generate.
  66.  
  67. JPEG files are in the defacto standard JFIF file format.  There are other,
  68. less widely used JPEG-based file formats, but we don't support them.
  69.  
  70. All switch names may be abbreviated; for example, -grayscale may be written
  71. -gray or -gr.  Most of the "basic" switches can be abbreviated to as little as
  72. one letter.  Upper and lower case are equivalent (-GIF is the same as -gif).
  73. British spellings are also accepted (e.g., -greyscale), though for brevity
  74. these are not mentioned below.
  75.  
  76.  
  77. CJPEG DETAILS
  78.  
  79. The basic command line switches for cjpeg are:
  80.  
  81.     -quality N    Scale quantization tables to adjust image quality.
  82.             Quality is 0 (worst) to 100 (best); default is 75.
  83.             (See below for more info.)
  84.  
  85.     -grayscale    Create monochrome JPEG file from color input.
  86.             Be sure to use this switch when compressing a grayscale
  87.             GIF file, because cjpeg isn't bright enough to notice
  88.             whether a GIF file uses only shades of gray.  By
  89.             saying -grayscale, you'll get a smaller JPEG file that
  90.             takes less time to process.
  91.  
  92.     -optimize    Perform optimization of entropy encoding parameters.
  93.             Without this, default encoding parameters are used.
  94.             -optimize usually makes the JPEG file a little smaller,
  95.             but cjpeg runs somewhat slower and needs much more
  96.             memory.  Image quality and speed of decompression are
  97.             unaffected by -optimize.
  98.  
  99.     -progressive    Create progressive JPEG file (see below).
  100.  
  101.     -targa        Input file is Targa format.  Targa files that contain
  102.             an "identification" field will not be automatically
  103.             recognized by cjpeg; for such files you must specify
  104.             -targa to make cjpeg treat the input as Targa format.
  105.             For most Targa files, you won't need this switch.
  106.  
  107. The -quality switch lets you trade off compressed file size against quality of
  108. the reconstructed image: the higher the quality setting, the larger the JPEG
  109. file, and the closer the output image will be to the original input.  Normally
  110. you want to use the lowest quality setting (smallest file) that decompresses
  111. into something visually indistinguishable from the original image.  For this
  112. purpose the quality setting should be between 50 and 95; the default of 75 is
  113. often about right.  If you see defects at -quality 75, then go up 5 or 10
  114. counts at a time until you are happy with the output image.  (The optimal
  115. setting will vary from one image to another.)
  116.  
  117. -quality 100 will generate a quantization table of all 1's, minimizing loss
  118. in the quantization step (but there is still information loss in subsampling,
  119. as well as roundoff error).  This setting is mainly of interest for
  120. experimental purposes.  Quality values above about 95 are NOT recommended for
  121. normal use; the compressed file size goes up dramatically for hardly any gain
  122. in output image quality.
  123.  
  124. In the other direction, quality values below 50 will produce very small files
  125. of low image quality.  Settings around 5 to 10 might be useful in preparing an
  126. index of a large image library, for example.  Try -quality 2 (or so) for some
  127. amusing Cubist effects.  (Note: quality values below about 25 generate 2-byte
  128. quantization tables, which are considered optional in the JPEG standard.
  129. cjpeg emits a warning message when you give such a quality value, because some
  130. other JPEG programs may be unable to decode the resulting file.  Use -baseline
  131. if you need to ensure compatibility at low quality values.)
  132.  
  133. The -progressive switch creates a "progressive JPEG" file.  In this type of
  134. JPEG file, the data is stored in multiple scans of increasing quality.  If the
  135. file is being transmitted over a slow communications link, the decoder can use
  136. the first scan to display a low-quality image very quickly, and can then
  137. improve the display with each subsequent scan.  The final image is exactly
  138. equivalent to a standard JPEG file of the same quality setting, and the total
  139. file size is about the same --- often a little smaller.  CAUTION: progressive
  140. JPEG is not yet widely implemented, so many decoders will be unable to view a
  141. progressive JPEG file at all.
  142.  
  143. Switches for advanced users:
  144.  
  145.     -dct int    Use integer DCT method (default).
  146.     -dct fast    Use fast integer DCT (less accurate).
  147.     -dct float    Use floating-point DCT method.
  148.             The float method is very slightly more accurate than
  149.             the int method, but is much slower unless your machine
  150.             has very fast floating-point hardware.  Also note that
  151.             results of the floating-point method may vary slightly
  152.             across machines, while the integer methods should give
  153.             the same results everywhere.  The fast integer method
  154.             is much less accurate than the other two.
  155.  
  156.     -restart N    Emit a JPEG restart marker every N MCU rows, or every
  157.             N MCU blocks if "B" is attached to the number.
  158.             -restart 0 (the default) means no restart markers.
  159.  
  160.     -smooth N    Smooth the input image to eliminate dithering noise.
  161.             N, ranging from 1 to 100, indicates the strength of
  162.             smoothing.  0 (the default) means no smoothing.
  163.  
  164.     -maxmemory N    Set limit for amount of memory to use in processing
  165.             large images.  Value is in thousands of bytes, or
  166.             millions of bytes if "M" is attached to the number.
  167.             For example, -max 4m selects 4000000 bytes.  If more
  168.             space is needed, temporary files will be used.
  169.  
  170.     -verbose    Enable debug printout.  More -v's give more printout.
  171.     or  -debug    Also, version information is printed at startup.
  172.  
  173. The -restart option inserts extra markers that allow a JPEG decoder to
  174. resynchronize after a transmission error.  Without restart markers, any damage
  175. to a compressed file will usually ruin the image from the point of the error
  176. to the end of the image; with restart markers, the damage is usually confined
  177. to the portion of the image up to the next restart marker.  Of course, the
  178. restart markers occupy extra space.  We recommend -restart 1 for images that
  179. will be transmitted across unreliable networks such as Usenet.
  180.  
  181. The -smooth option filters the input to eliminate fine-scale noise.  This is
  182. often useful when converting GIF files to JPEG: a moderate smoothing factor of
  183. 10 to 50 gets rid of dithering patterns in the input file, resulting in a
  184. smaller JPEG file and a better-looking image.  Too large a smoothing factor
  185. will visibly blur the image, however.
  186.  
  187. Switches for wizards:
  188.  
  189.     -baseline    Force a baseline JPEG file to be generated.  This
  190.             clamps quantization values to 8 bits even at low
  191.             quality settings.
  192.  
  193.     -qtables file    Use the quantization tables given in the specified
  194.             text file.
  195.  
  196.     -qslots N[,...] Select which quantization table to use for each color
  197.             component.
  198.  
  199.     -sample HxV[,...]  Set JPEG sampling factors for each color component.
  200.  
  201.     -scans file    Use the scan script given in the specified text file.
  202.  
  203. The "wizard" switches are intended for experimentation with JPEG.  If you
  204. don't know what you are doing, DON'T USE THEM.  These switches are documented
  205. further in the file wizard.doc.
  206.  
  207.  
  208. DJPEG DETAILS
  209.  
  210. The basic command line switches for djpeg are:
  211.  
  212.     -colors N    Reduce image to at most N colors.  This reduces the
  213.     or -quantize N    number of colors used in the output image, so that it
  214.             can be displayed on a colormapped display or stored in
  215.             a colormapped file format.  For example, if you have
  216.             an 8-bit display, you'd need to reduce to 256 or fewer
  217.             colors.  (-colors is the recommended name, -quantize
  218.             is provided only for backwards compatibility.)
  219.  
  220.     -fast        Select recommended processing options for fast, low
  221.             quality output.  (The default options are chosen for
  222.             highest quality output.)  Currently, this is equivalent
  223.             to "-dct fast -nosmooth -onepass -dither ordered".
  224.  
  225.     -grayscale    Force gray-scale output even if JPEG file is color.
  226.             Useful for viewing on monochrome displays; also,
  227.             djpeg runs noticeably faster in this mode.
  228.  
  229.     -scale M/N    Scale the output image by a factor M/N.  Currently
  230.             the scale factor must be 1/1, 1/2, 1/4, or 1/8.
  231.             Scaling is handy if the image is larger than your
  232.             screen; also, djpeg runs much faster when scaling
  233.             down the output.
  234.  
  235.     -bmp        Select BMP output format (Windows flavor).  8-bit
  236.             colormapped format is emitted if -colors or -grayscale
  237.             is specified, or if the JPEG file is gray-scale;
  238.             otherwise, 24-bit full-color format is emitted.
  239.  
  240.     -gif        Select GIF output format (this is the default).
  241.             Since GIF does not support more than 256 colors,
  242.             -colors 256 is assumed (unless you specify a smaller
  243.             number of colors).  If you specify -fast, the
  244.             default number of colors is 216.
  245.  
  246.     -os2        Select BMP output format (OS/2 1.x flavor).  8-bit
  247.             colormapped format is emitted if -colors or -grayscale
  248.             is specified, or if the JPEG file is gray-scale;
  249.             otherwise, 24-bit full-color format is emitted.
  250.  
  251.     -pnm        Select PBMPLUS (PPM/PGM) output format.  PGM is
  252.             emitted if the JPEG file is gray-scale or if
  253.             -grayscale is specified; otherwise PPM is emitted.
  254.  
  255.     -rle        Select RLE output format.  (Requires URT library.)
  256.  
  257.     -targa        Select Targa output format.  Gray-scale format is
  258.             emitted if the JPEG file is gray-scale or if
  259.             -grayscale is specified; otherwise, colormapped format
  260.             is emitted if -colors is specified; otherwise, 24-bit
  261.             full-color format is emitted.
  262.  
  263. Switches for advanced users:
  264.  
  265.     -dct int    Use integer DCT method (default).
  266.     -dct fast    Use fast integer DCT (less accurate).
  267.     -dct float    Use floating-point DCT method.
  268.             The float method is very slightly more accurate than
  269.             the int method, but is much slower unless your machine
  270.             has very fast floating-point hardware.  Also note that
  271.             results of the floating-point method may vary slightly
  272.             across machines, while the integer methods should give
  273.             the same results everywhere.  The fast integer method
  274.             is much less accurate than the other two.
  275.  
  276.     -dither fs    Use Floyd-Steinberg dithering in color quantization.
  277.     -dither ordered    Use ordered dithering in color quantization.
  278.     -dither none    Do not use dithering in color quantization.
  279.             By default, Floyd-Steinberg dithering is applied when
  280.             quantizing colors; this is slow but usually produces
  281.             the best results.  Ordered dither is a compromise
  282.             between speed and quality; no dithering is fast but
  283.             usually looks awful.  Note that these switches have
  284.             no effect unless color quantization is being done.
  285.             Ordered dither is only available in -onepass mode.
  286.  
  287.     -map FILE    Quantize to the colors used in the specified image
  288.             file.  This is useful for producing multiple files
  289.             with identical color maps, or for forcing a predefined
  290.             set of colors to be used.  The FILE must be a GIF
  291.             or PPM file.  This option overrides -colors and
  292.             -onepass.
  293.  
  294.     -nosmooth    Use a faster, lower-quality upsampling routine.
  295.  
  296.     -onepass    Use one-pass instead of two-pass color quantization.
  297.             The one-pass method is faster and needs less memory,
  298.             but it produces a lower-quality image.  -onepass is
  299.             ignored unless you also say -colors N.  Also,
  300.             the one-pass method is always used for gray-scale
  301.             output (the two-pass method is no improvement then).
  302.  
  303.     -maxmemory N    Set limit for amount of memory to use in processing
  304.             large images.  Value is in thousands of bytes, or
  305.             millions of bytes if "M" is attached to the number.
  306.             For example, -max 4m selects 4000000 bytes.  If more
  307.             space is needed, temporary files will be used.
  308.  
  309.     -verbose    Enable debug printout.  More -v's give more printout.
  310.     or  -debug    Also, version information is printed at startup.
  311.  
  312.  
  313. HINTS FOR CJPEG
  314.  
  315. Color GIF files are not the ideal input for JPEG; JPEG is really intended for
  316. compressing full-color (24-bit) images.  In particular, don't try to convert
  317. cartoons, line drawings, and other images that have only a few distinct
  318. colors.  GIF works great on these, JPEG does not.  If you want to convert a
  319. GIF to JPEG, you should experiment with cjpeg's -quality and -smooth options
  320. to get a satisfactory conversion.  -smooth 10 or so is often helpful.
  321.  
  322. Avoid running an image through a series of JPEG compression/decompression
  323. cycles.  Image quality loss will accumulate; after ten or so cycles the image
  324. may be noticeably worse than it was after one cycle.  It's best to use a
  325. lossless format while manipulating an image, then convert to JPEG format when
  326. you are ready to file the image away.
  327.  
  328. The -optimize option to cjpeg is worth using when you are making a "final"
  329. version for posting or archiving.  It's also a win when you are using low
  330. quality settings to make very small JPEG files; the percentage improvement
  331. is often a lot more than it is on larger files.  (At present, -optimize
  332. mode is always selected when generating progressive JPEG files.)
  333.  
  334.  
  335. HINTS FOR DJPEG
  336.  
  337. To get a quick preview of an image, use the -grayscale and/or -scale switches.
  338. "-grayscale -scale 1/8" is the fastest case.
  339.  
  340. Several options are available that trade off image quality to gain speed.
  341. "-fast" turns on the recommended settings.
  342.  
  343. "-dct fast" and/or "-nosmooth" gain speed at a small sacrifice in quality.
  344. When producing a color-quantized image, "-onepass -dither ordered" is fast but
  345. much lower quality than the default behavior.  "-dither none" may give
  346. acceptable results in two-pass mode, but is seldom tolerable in one-pass mode.
  347.  
  348. If you are fortunate enough to have very fast floating point hardware,
  349. "-dct float" may be even faster than "-dct fast".  But on most machines
  350. "-dct float" is slower than "-dct int"; in this case it is not worth using,
  351. because its theoretical accuracy advantage is too small to be significant
  352. in practice.
  353.  
  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.  
  359.  
  360. HINTS FOR BOTH PROGRAMS
  361.  
  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.  
  370. On MS-DOS, the temporary files are created in the directory named by the TMP
  371. or TEMP environment variable, or in the current directory if neither of those
  372. exist.  Amiga implementations put the temp files in the directory named by
  373. JPEGTMP:, so be sure to assign JPEGTMP: to a disk partition with adequate free
  374. space.
  375.  
  376. On MS-DOS machines, -maxmemory is the amount of main (conventional) memory to
  377. use.  (Extended or expanded memory is also used if available.)  Most
  378. DOS-specific versions of this software do their own memory space estimation
  379. and do not need you to specify -maxmemory.
  380.  
  381.  
  382. JPEGTRAN
  383.  
  384. jpegtran translates JPEG files from one variant of JPEG to another, for
  385. example from baseline JPEG to progressive JPEG or vice versa.  The
  386. transformation is lossless: no image degradation occurs, which would not
  387. be true if you used djpeg followed by cjpeg.  However, you cannot alter
  388. the image quality, because that would not be a lossless operation.
  389.  
  390. The command line syntax for jpegtran is
  391.     jpegtran [switches] inputfilename outputfilename
  392. where both input and output JPEG file names must be given explicitly.
  393.  
  394. jpegtran accepts a subset of the switches recognized by cjpeg:
  395.     -optimize
  396.     -progressive
  397.     -restart N
  398.     -scans file
  399.     -maxmemory N
  400.     -verbose
  401.     -debug
  402. See the previous discussion of cjpeg for details about these switches.
  403.  
  404. If you specify no switches, you get a plain baseline-JPEG output file.
  405.  
  406.  
  407. THE COMMENT UTILITIES
  408.  
  409. The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file.
  410. Although the standard doesn't actually define what COM blocks are for, they
  411. are widely used to hold user-supplied text strings.  This lets you add
  412. annotations, titles, index terms, etc to your JPEG files, and later retrieve
  413. them as text.  COM blocks do not interfere with the image stored in the JPEG
  414. file.  The maximum size of a COM block is 64K, but you can have as many of
  415. them as you like in one JPEG file.
  416.  
  417. We provide two utility programs to display COM block contents and add COM
  418. blocks to a JPEG file.
  419.  
  420. rdjpgcom searches a JPEG file and prints the contents of any COM blocks on
  421. standard output.  The command line syntax is
  422.     rdjpgcom [-verbose] [inputfilename]
  423. The switch "-verbose" (or just "-v") causes rdjpgcom to also display the JPEG
  424. image dimensions.  If you omit the input file name from the command line,
  425. the JPEG file is read from standard input.  (This may not work on some
  426. operating systems, if binary data can't be read from stdin.)
  427.  
  428. wrjpgcom adds a COM block, containing text you provide, to a JPEG file.
  429. Ordinarily, the COM block is added after any existing COM blocks, but you
  430. can delete the old COM blocks if you wish.  wrjpgcom produces a new JPEG
  431. file; it does not modify the input file.  DO NOT try to overwrite the input
  432. file by directing wrjpgcom's output back into it; on most systems this will
  433. just destroy your file.
  434.  
  435. The command line syntax for wrjpgcom is
  436.     wrjpgcom [switches] inputfilename outputfilename
  437. where both input and output file names must be given explicitly.
  438.  
  439. wrjpgcom understands three switches:
  440.     -replace         Delete any existing COM blocks from the file.
  441.     -comment "Comment text"     Supply new COM text on command line.
  442.         -cfile name         Read text for new COM block from named file.
  443. (Switch names can be abbreviated.)  If you have only one line of comment text
  444. to add, you can provide it on the command line with -comment.  The comment
  445. text must be surrounded with quotes so that it is treated as a single
  446. argument.  Longer comments can be read from a text file.
  447.  
  448. If you give neither -comment nor -cfile, then wrjpgcom will read the comment
  449. text from standard input.  You can enter multiple lines, up to 64KB worth.
  450. Type an end-of-file indicator (control-Z) to terminate the comment text entry.
  451.  
  452. wrjpgcom will not add a COM block if the provided comment string is empty.
  453. Therefore -replace -comment "" can be used to delete all COM blocks from a
  454. file.
  455.