home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / compresn / jpegv3sr / usage < prev   
Text File  |  1992-03-17  |  10KB  |  213 lines

  1. USAGE instructions for the Independent JPEG Group's JPEG software
  2. =================================================================
  3.  
  4. INTRODUCTION
  5.  
  6. This distribution contains software to implement JPEG image compression and
  7. decompression.  JPEG (pronounced "jay-peg") is a standardized compression
  8. method for full-color and gray-scale images.  JPEG is designed to handle
  9. "real-world" scenes, for example scanned photographs.  Cartoons, line
  10. drawings, and other non-realistic images are not JPEG's strong suit; on this
  11. sort of material 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. This file describes usage of the standard programs "cjpeg" and "djpeg" that
  21. can be built directly from the distributed C code.  See the README file for
  22. hints on incorporating the JPEG software into other programs.
  23.  
  24. If you are on a Unix machine you may prefer to read the Unix-style manual
  25. pages in files cjpeg.1 and djpeg.1.
  26.  
  27. NOTE: at some point we will probably redesign the user interface, so the
  28. command line switches described here will change.
  29.  
  30.  
  31. GENERAL USAGE
  32.  
  33. We provide two programs, cjpeg to compress an image file into JPEG format,
  34. and djpeg to decompress a JPEG file back into a conventional image format.
  35.  
  36. On Unix-like systems, you say:
  37.     cjpeg [switches] [imagefile] >jpegfile
  38. or
  39.     djpeg [switches] [jpegfile]  >imagefile
  40. The programs read the specified input file, or standard input if none is
  41. named.  They always write to standard output (with trace/error messages to
  42. standard error).  These conventions are handy for piping images between
  43. programs.
  44.  
  45. On most non-Unix systems, you say:
  46.     cjpeg [switches] imagefile jpegfile
  47. or
  48.     djpeg [switches] jpegfile  imagefile
  49. i.e., both the input and output files are named on the command line.  This
  50. style is a little more foolproof, and it loses no functionality if you don't
  51. have pipes.  (You can get this style on Unix too, if you prefer, by defining
  52. TWO_FILE_COMMANDLINE when you compile the programs; see SETUP.)
  53.  
  54. The currently supported image file formats are: PPM (PBMPLUS color format),
  55. PGM (PBMPLUS gray-scale format), GIF, Targa, and RLE (Utah Raster Toolkit
  56. format).  (RLE is supported only if the URT library is available.)
  57. cjpeg recognizes the input image format automatically, with the exception
  58. of some Targa-format files.  You have to tell djpeg which format to generate.
  59.  
  60. The only JPEG file format currently supported is the JFIF format.  Support for
  61. the TIFF/JPEG format will probably be added at some future date.
  62.  
  63.  
  64. CJPEG DETAILS
  65.  
  66. The command line switches for cjpeg are:
  67.  
  68.     -Q quality    Scale quantization tables to adjust image quality.
  69.             Quality is 0 (worst) to 100 (best); default is 75.
  70.             (See below for more info.)
  71.  
  72.     -o        Perform optimization of entropy encoding parameters.
  73.             Without this, default encoding parameters are used.
  74.             -o usually makes the JPEG file a little smaller, but
  75.             cjpeg runs somewhat slower and needs much more memory.
  76.             Image quality and speed of decompression are unaffected
  77.             by -o.
  78.  
  79.     -T        Input file is Targa format.  Targa files that contain
  80.             an "identification" field will not be automatically
  81.             recognized by cjpeg; for such files you must specify
  82.             -T to force cjpeg to treat the input as Targa format.
  83.  
  84.     -I        Generate noninterleaved JPEG file (not yet supported).
  85.  
  86.     -a        Use arithmetic coding rather than Huffman coding.
  87.             (Not currently supported for legal reasons.)
  88.  
  89.     -d        Enable debug printout.  More -d's give more printout.
  90.             Also, version information is printed at startup.
  91.  
  92.     -m memory    Set limit for amount of memory to use in processing
  93.             large images.  Value is in thousands of bytes, or
  94.             millions of bytes if "M" is attached to the number.
  95.             For example, -m 4m selects 4000000 bytes.  If more
  96.             space is needed, temporary files will be used.
  97.  
  98. The -Q switch lets you trade off compressed file size against quality of the
  99. reconstructed image: the higher the -Q setting, the larger the JPEG file, and
  100. the closer the output image will be to the original input.  Normally you want
  101. to use the lowest -Q setting (smallest file) that decompresses into something
  102. visually indistinguishable from the original image.  For this purpose the -Q
  103. setting should be between 50 and 95; the default of 75 is often about right.
  104. If you see defects at -Q 75, then go up 5 or 10 counts at a time until you are
  105. happy with the output image.  (The optimal setting will vary from one image to
  106. another.)
  107.  
  108. -Q 100 will generate a quantization table of all 1's, eliminating loss in the
  109. quantization step (but there is still information loss in subsampling, as well
  110. as roundoff error).  This setting is mainly of interest for experimental
  111. purposes.  -Q values above about 95 are NOT recommended for normal use; the
  112. compressed file size goes up dramatically for hardly any gain in output image
  113. quality.
  114.  
  115. In the other direction, -Q values below 50 will produce very small files of
  116. low image quality.  Settings around 5 to 10 might be useful in preparing an
  117. index of a large image library, for example.  Try -Q 2 (or so) for some
  118. amusing Cubist effects.  (Note: -Q values below about 25 generate 2-byte
  119. quantization tables, which are considered optional in the JPEG standard.
  120. cjpeg emits a warning message when you give such a -Q value, because some
  121. commercial JPEG programs may be unable to decode the resulting file.)
  122.  
  123.  
  124. DJPEG DETAILS
  125.  
  126. The command line switches for djpeg are:
  127.  
  128.     -G        Select GIF output format (implies -q, with default
  129.             of 256 colors).
  130.  
  131.     -P        Select PPM or PGM output format (this is the default).
  132.             PGM is emitted if the JPEG file is gray-scale or if -g
  133.             is specified.
  134.  
  135.     -R        Select RLE output format.  Requires URT library.
  136.  
  137.     -T        Select Targa output format.  Gray-scale format is
  138.             emitted if the JPEG file is gray-scale or if -g is
  139.             specified; otherwise, colormapped format is emitted
  140.             if -q is specified; otherwise, 24-bit full-color
  141.             format is emitted.
  142.  
  143.     -g        Force gray-scale output even if input is color.
  144.  
  145.     -q N        Quantize to N colors.  This reduces the number of
  146.             colors in the output image so that it can be displayed
  147.             on a colormapped display or stored in a colormapped
  148.             file format.  For example, if you have an 8-bit
  149.             display, you'd need to quantize to 256 or fewer colors.
  150.  
  151.     -D        Do not use dithering in color quantization.
  152.             By default, Floyd-Steinberg dithering is applied when
  153.             quantizing colors, but on some images dithering may
  154.             result in objectionable "graininess".  If that
  155.             happens, you can turn off dithering with -D.
  156.             -D is ignored unless you also say -q or -G.
  157.  
  158.     -1        Use one-pass instead of two-pass color quantization.
  159.             The one-pass method is faster and needs less memory,
  160.             but it produces a lower-quality image.
  161.             -1 is ignored unless you also say -q or -G.  Also,
  162.             the one-pass method is always used for gray-scale
  163.             output (the two-pass method is no improvement then).
  164.  
  165.     -b        Perform cross-block smoothing.  This is quite
  166.             memory-intensive and only seems to improve the image
  167.             at very low quality settings (-Q 10 to 20 or so).
  168.             At normal -Q settings it may make the image worse.
  169.  
  170.     -d        Enable debug printout.  More -d's give more printout.
  171.             Also, version information is printed at startup.
  172.  
  173.     -m memory    Set limit for amount of memory to use in processing
  174.             large images.  Value is in thousands of bytes, or
  175.             millions of bytes if "M" is attached to the number.
  176.             For example, -m 4m selects 4000000 bytes.  If more
  177.             space is needed, temporary files will be used.
  178.  
  179.  
  180. HINTS
  181.  
  182. Avoid running an image through a series of JPEG compression/decompression
  183. cycles.  Image quality loss will accumulate; after ten or so cycles the image
  184. may be noticeably worse than it was after one cycle.  It's best to use a
  185. lossless format while manipulating an image, then convert to JPEG format when
  186. you are ready to file the image away.
  187.  
  188. The -o option to cjpeg is worth using when you are making a "final" version
  189. for posting or archiving.  It's also a win when you are using low -Q settings
  190. to make very small JPEG files; the percentage improvement is often a lot more
  191. than it is on larger files.
  192.  
  193. The default memory usage limit (-m) is set when the software is compiled.
  194. If you get an "insufficient memory" error, try specifying a smaller -m value,
  195. even -m 0 to use the absolute minimum space.  You may want to recompile with
  196. a smaller default value if this happens often.
  197.  
  198. djpeg with two-pass color quantization requires a good deal of space; on
  199. MS-DOS machines it may run out of memory even with -m 0.  In that case you
  200. can still decompress, with some loss of image quality, by specifying -1
  201. for one-pass quantization.
  202.  
  203. If more space is needed than will fit in the available main memory (as
  204. determined by -m), temporary files will be used.  (MS-DOS versions will try to
  205. get extended or expanded memory first.)  The temporary files are often rather
  206. large: in typical cases they occupy three bytes per pixel, for example
  207. 3*800*600 = 1.44Mb for an 800x600 image.  If you don't have enough free disk
  208. space, leave out -o (for cjpeg) or specify -1 (for djpeg).  On MS-DOS, the
  209. temporary files are created in the directory named by the TMP or TEMP
  210. environment variable, or in the current directory if neither of those exist.
  211. Amiga implementations put the temp files in the directory named by JPEGTMP:,
  212. so be sure to assign JPEGTMP: to a disk partition with adequate free space.
  213.