home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Information / Specifications / Graphics / JPEG / jpeg-faq
Encoding:
Text File  |  1994-12-03  |  61.8 KB  |  1,154 lines  |  [TEXT/R*ch]

  1. Newsgroups: comp.graphics,alt.graphics.pixutils,alt.binaries.pictures.utilities,alt.binaries.pictures.d,alt.binaries.pictures.erotica.d,comp.answers,alt.answers,news.answers
  2. Path: bloom-beacon.mit.edu!usc!howland.reston.ans.net!ix.netcom.com!netcom.com!tgl
  3. From: tgl@netcom.com (Tom Lane)
  4. Subject: JPEG image compression: Frequently Asked Questions
  5. Message-ID: <jpeg-faq_785952222@netcom.com>
  6. Followup-To: comp.graphics
  7. Summary: Useful info about JPEG (JPG) image files and programs
  8. Keywords: JPEG, image compression, FAQ, JPG, JFIF
  9. Supersedes: <jpeg-faq_784744872@netcom.com>
  10. Reply-To: jpeg-info@uunet.uu.net
  11. Organization: Independent JPEG Group
  12. Date: Sun, 27 Nov 1994 16:03:44 GMT
  13. Approved: news-answers-request@MIT.Edu
  14. Expires: Sun, 25 Dec 1994 16:03:42 GMT
  15. Lines: 1136
  16. Xref: bloom-beacon.mit.edu comp.graphics:34383 alt.graphics.pixutils:4735 alt.binaries.pictures.utilities:22658 alt.binaries.pictures.d:11708 alt.binaries.pictures.erotica.d:30390 comp.answers:8580 alt.answers:5896 news.answers:30109
  17.  
  18. Archive-name: jpeg-faq
  19. Last-modified: 13 November 1994
  20.  
  21. This article discusses JPEG image compression.  Suggestions for additions
  22. and clarifications are welcome.
  23.  
  24. New since version of 30 October 1994:
  25.   * New version of ImageMagick (3.4).
  26.   * IJG version 5 executables available for Amiga and Acorn.
  27.  
  28.  
  29. This article includes the following sections:
  30.  
  31. [1]  What is JPEG?
  32. [2]  Why use JPEG?
  33. [3]  When should I use JPEG, and when should I stick with GIF?
  34. [4]  How well does JPEG compress images?
  35. [5]  What are good "quality" settings for JPEG?
  36. [6]  Where can I get JPEG software?
  37.     [6A] viewers, application programs, etc.
  38.     [6B] source code
  39. [7]  What's all this hoopla about color quantization?
  40. [8]  What are some rules of thumb for converting GIF images to JPEG?
  41. [9]  Does loss accumulate with repeated compression/decompression?
  42. [10]  Why all the argument about file formats?
  43. [11]  How do I recognize which file format I have, and what do I do about it?
  44. [12]  How does JPEG work?
  45. [13]  Isn't there a lossless JPEG?
  46. [14]  What about arithmetic coding?
  47. [15]  Could an FPU speed up JPEG?  How about a DSP chip?
  48.  
  49. Sections 1-6 are basic info that every JPEG user needs to know;
  50. sections 7-15 are more advanced info.
  51.  
  52. This article is posted every 2 weeks.  You can always find the latest
  53. version in the news.answers archive at rtfm.mit.edu (18.181.0.24).  By FTP,
  54. fetch rtfm.mit.edu:/pub/usenet/news.answers/jpeg-faq.  If you don't have
  55. FTP, send e-mail to mail-server@rtfm.mit.edu containing the line
  56.     send usenet/news.answers/jpeg-faq
  57. (If you don't get a reply, the server may be misreading your return address;
  58. add a line such as "path myname@mysite" to specify your correct e-mail
  59. address to reply to.)  Many other FAQ articles are available in the
  60. news.answers archive, which is also accessible via WAIS, WWW, and Gopher.
  61. On WWW, see http://www.cis.ohio-state.edu/hypertext/faq/usenet/FAQ-List.html.
  62. For more information about the archive, retrieve the file
  63. rtfm.mit.edu:/pub/usenet/news.answers/news-answers/introduction.
  64.  
  65.  
  66. ----------
  67.  
  68.  
  69. [1]  What is JPEG?
  70.  
  71. JPEG (pronounced "jay-peg") is a standardized image compression mechanism.
  72. JPEG stands for Joint Photographic Experts Group, the original name of the
  73. committee that wrote the standard.
  74.  
  75. JPEG is designed for compressing either full-color or gray-scale images
  76. of natural, real-world scenes.  It works well on photographs, naturalistic
  77. artwork, and similar material; not so well on lettering, simple cartoons,
  78. or line drawings.  JPEG handles only still images, but there is a related
  79. standard called MPEG for motion pictures.
  80.  
  81. JPEG is "lossy," meaning that the decompressed image isn't quite the same as
  82. the one you started with.  (There are lossless image compression algorithms,
  83. but JPEG achieves much greater compression than is possible with lossless
  84. methods.)  JPEG is designed to exploit known limitations of the human eye,
  85. notably the fact that small color changes are perceived less accurately than
  86. small changes in brightness.  Thus, JPEG is intended for compressing images
  87. that will be looked at by humans.  If you plan to machine-analyze your
  88. images, the small errors introduced by JPEG may be a problem for you, even
  89. if they are invisible to the eye.
  90.  
  91. A useful property of JPEG is that the degree of lossiness can be varied by
  92. adjusting compression parameters.  This means that the image maker can trade
  93. off file size against output image quality.  You can make *extremely* small
  94. files if you don't mind poor quality; this is useful for applications like
  95. indexing image archives.  Conversely, if you aren't happy with the output
  96. quality at the default compression setting, you can jack up the quality
  97. until you are satisfied, and accept lesser compression.
  98.  
  99. Another important aspect of JPEG is that decoders can trade off decoding
  100. speed against image quality, by using fast but inaccurate approximations to
  101. the required calculations.  Until recently, most publicly available JPEG
  102. code has adopted a best-possible-quality philosophy, but we are now starting
  103. to see the appearance of viewers that give up some image quality in order to
  104. obtain significant speedups.
  105.  
  106.  
  107. [2]  Why use JPEG?
  108.  
  109. There are two good reasons: to make your image files smaller, and to store
  110. 24-bit-per-pixel color data instead of 8-bit-per-pixel data.
  111.  
  112. Making image files smaller is a big win for transmitting files across
  113. networks and for archiving libraries of images.  Being able to compress a
  114. 2 Mbyte full-color file down to 100 Kbytes or so makes a big difference in
  115. disk space and transmission time!  (If you are comparing GIF and JPEG, the
  116. size ratio is more like four to one.  More details in section 4.)
  117.  
  118. If your viewing software doesn't support JPEG directly, you'll have to
  119. convert JPEG to some other format for viewing or manipulating images.  Even
  120. with a JPEG-capable viewer, it takes longer to decode and view a JPEG image
  121. than to view an image of a simpler format such as GIF.  Thus, using JPEG is
  122. essentially a time/space tradeoff: you give up some time in order to store
  123. or transmit an image more cheaply.
  124.  
  125. It's worth noting that when network or phone transmission is involved, the
  126. time savings from transferring a shorter file can be greater than the extra
  127. time needed to decompress the file.
  128.  
  129. The second fundamental advantage of JPEG is that it stores full color
  130. information: 24 bits/pixel (16 million colors).  GIF, the other image format
  131. widely used on Usenet, can only store 8 bits/pixel (256 or fewer colors).
  132. GIF is reasonably well matched to inexpensive computer displays --- most
  133. run-of-the-mill PCs can't display more than 256 distinct colors at once.
  134. But full-color hardware is getting cheaper all the time, and JPEG images
  135. look *much* better than GIFs on such hardware.  Within a couple of years,
  136. 8-bit GIF will seem as obsolete as black-and-white MacPaint format does
  137. today.  Furthermore, for reasons detailed in section 7, JPEG is far more
  138. useful than GIF for exchanging images among people with widely varying
  139. display hardware.  Hence JPEG is considerably more appropriate than GIF for
  140. use as a Usenet posting standard.
  141.  
  142. A lot of people are scared off by the term "lossy compression".  But when
  143. it comes to representing real-world scenes, *no* digital image format can
  144. retain all the information that impinges on your eyeball.  By comparison
  145. with the real-world scene, JPEG loses far less information than GIF.  The
  146. technical meaning of "lossy" has nothing to do with this, though; it refers
  147. to loss of information over repeated compression cycles, a problem that you
  148. may or may not care about.  (If you do, see section 9.)
  149.  
  150.  
  151. [3]  When should I use JPEG, and when should I stick with GIF?
  152.  
  153. JPEG is *not* going to displace GIF entirely; for some types of images,
  154. GIF is superior in image quality, file size, or both.  One of the first
  155. things to learn about JPEG is which kinds of images to apply it to.
  156.  
  157. Generally speaking, JPEG is superior to GIF for storing full-color or
  158. gray-scale images of "realistic" scenes; that means scanned photographs and
  159. similar material.  Any continuous variation in color, such as occurs in
  160. highlighted or shaded areas, will be represented more faithfully and in less
  161. space by JPEG than by GIF.
  162.  
  163. GIF does significantly better on images with only a few distinct colors,
  164. such as line drawings and simple cartoons.  Not only is GIF lossless for
  165. such images, but it often compresses them more than JPEG can.  For example,
  166. large areas of pixels that are all *exactly* the same color are compressed
  167. very efficiently indeed by GIF.  JPEG can't squeeze such data as much as GIF
  168. does without introducing visible defects.  (One implication of this is that
  169. large single-color borders are quite cheap in GIF files, while they are best
  170. avoided in JPEG files.)
  171.  
  172. Computer-drawn images (ray-traced scenes, for instance) usually fall between
  173. photographs and cartoons in terms of complexity.  The more complex and
  174. subtly rendered the image, the more likely that JPEG will do well on it.
  175. The same goes for semi-realistic artwork (fantasy drawings and such).
  176.  
  177. JPEG has a hard time with very sharp edges: a row of pure-black pixels
  178. adjacent to a row of pure-white pixels, for example.  Sharp edges tend to
  179. come out blurred unless you use a very high quality setting.  Edges this
  180. sharp are rare in scanned photographs, but are fairly common in GIF files:
  181. borders, overlaid text, etc.  The blurriness is particularly objectionable
  182. with text that's only a few pixels high.  If you have a GIF with a lot of
  183. small-size overlaid text, don't JPEG it.
  184.  
  185. Plain black-and-white (two level) images should never be converted to JPEG;
  186. they violate all of the conditions given above.  You need at least about
  187. 16 gray levels before JPEG is useful for gray-scale images.  It should also
  188. be noted that GIF is lossless for gray-scale images of up to 256 levels,
  189. while JPEG is not.
  190.  
  191. If you have a large library of GIF images, you may want to save space by
  192. converting the GIFs to JPEG.  This is trickier than it may seem --- even
  193. when the GIFs contain photographic images, they are actually very poor
  194. source material for JPEG, because the images have been color-reduced.
  195. Non-photographic images should generally be left in GIF form.  Good-quality
  196. photographic GIFs can often be converted with no visible quality loss, but
  197. only if you know what you are doing and you take the time to work on each
  198. image individually.  Otherwise you're likely to lose a lot of image quality
  199. or waste a lot of disk space ... quite possibly both.  Read sections 7 and 8
  200. if you want to convert GIFs to JPEG.
  201.  
  202.  
  203. [4]  How well does JPEG compress images?
  204.  
  205. Very well indeed, when working with its intended type of image (photographs
  206. and suchlike).  For full-color images, the uncompressed data is normally 24
  207. bits/pixel.  The best known lossless compression methods can compress such
  208. data about 2:1 on average.  JPEG can typically achieve 10:1 to 20:1
  209. compression without visible loss, bringing the effective storage requirement
  210. down to 1 to 2 bits/pixel.  30:1 to 50:1 compression is possible with small
  211. to moderate defects, while for very-low-quality purposes such as previews or
  212. archive indexes, 100:1 compression is quite feasible.  An image compressed
  213. 100:1 with JPEG takes up the same space as a full-color one-tenth-scale
  214. thumbnail image, yet it retains much more detail than such a thumbnail.
  215.  
  216. For comparison, a GIF version of the same image would start out by
  217. sacrificing most of the color information to reduce the image to 256 colors
  218. (8 bits/pixel).  This provides 3:1 compression.  GIF has additional "LZW"
  219. compression built in, but LZW doesn't work very well on typical photographic
  220. data; at most you may get 5:1 compression overall, and it's not at all
  221. uncommon for LZW to be a net loss (less than 3:1 overall compression).
  222. When a JPEG file is made from full-color data, using a quality setting just
  223. high enough to prevent visible loss, the JPEG will typically be a factor of
  224. four or five smaller than a GIF file made from the same data.
  225.  
  226. Gray-scale images do not compress by such large factors.  Because the human
  227. eye is much more sensitive to brightness variations than to hue variations,
  228. JPEG can compress hue data more heavily than brightness (gray-scale) data.
  229. A gray-scale JPEG file is generally only about 10%-25% smaller than a
  230. full-color JPEG file of similar visual quality.  But the uncompressed
  231. gray-scale data is only 8 bits/pixel, or one-third the size of the color
  232. data, so the calculated compression ratio is much lower.  The threshold of
  233. visible loss is often around 5:1 compression for gray-scale images.
  234.  
  235. The exact threshold at which errors become visible depends on your viewing
  236. conditions.  The smaller an individual pixel, the harder it is to see an
  237. error; so errors are more visible on a computer screen (at maybe 70
  238. dots/inch) than on a high-quality color printout (300 or more dots/inch).
  239. Thus a higher-resolution image can tolerate more compression ... which is
  240. fortunate considering it's much bigger to start with.  The numbers quoted
  241. above are typical for screen viewing.  Also note that the threshold of
  242. visible error varies considerably across images.
  243.  
  244.  
  245. [5]  What are good "quality" settings for JPEG?
  246.  
  247. Most JPEG compressors let you pick a file size vs. image quality tradeoff by
  248. selecting a quality setting.  There seems to be widespread confusion about
  249. the meaning of these settings.  "Quality 95" does NOT mean "keep 95% of the
  250. information", as some have claimed.  The quality scale is purely arbitrary;
  251. it's not a percentage of anything.
  252.  
  253. In fact, quality scales aren't even standardized across JPEG programs.  The
  254. quality settings discussed in this article apply to the IJG JPEG software
  255. described in section 6B, and to many programs based on it.  Other JPEG
  256. implementations, notably Apple's and HSI's, use completely different quality
  257. scales; for instance, Apple's scale covers 0-4, not 0-100.  Some programs
  258. don't even provide a numeric scale, just "high"/"medium"/"low"-style
  259. choices.  (Fortunately, this doesn't prevent different implementations from
  260. exchanging compressed files.)
  261.  
  262. In most cases the user's goal is to pick the lowest quality setting, or
  263. smallest file size, that decompresses into an image indistinguishable from
  264. the original.  This setting will vary from one image to another and from one
  265. observer to another, but here are some rules of thumb.
  266.  
  267. For good-quality, full-color source images, the default quality setting
  268. (Q 75) is very often the best choice.  This setting is about the lowest you
  269. can go without expecting to see defects in a typical image.  Try Q 75 first;
  270. if you see defects, then go up.
  271.  
  272. If the image was less than perfect quality to begin with, you might be able
  273. to drop down to Q 50 without objectionable degradation.  On the other hand,
  274. you might need to go to a *higher* quality setting to avoid further loss.
  275. Q 85 to 95 is often best for converting GIFs (see section 8 for more info).
  276.  
  277. Except for experimental purposes, never go above about Q 95; using Q 100
  278. will produce a file two or three times as large as Q 95, but of hardly any
  279. better quality.  If you see a file made with Q 100, it's a pretty sure sign
  280. that the maker didn't know what he/she was doing.
  281.  
  282. If you want a very small file (say for preview or indexing purposes) and are
  283. prepared to tolerate large defects, a Q setting in the range of 5 to 10 is
  284. about right.  Q 2 or so may be amusing as "op art".
  285.  
  286.  
  287. [6]  Where can I get JPEG software?
  288.  
  289. Most of the programs described in this section are available by FTP.
  290. If you don't know how to use FTP, see the "Anonymous FTP FAQ List" article.
  291. (If you don't have direct access to FTP, read about ftpmail servers in the
  292. same article.)  That article appears regularly in news.answers, or you can
  293. get it by sending e-mail to mail-server@rtfm.mit.edu with the single line
  294. "send usenet/news.answers/ftp-list/faq" in the body.
  295.  
  296. NOTE: this list changes frequently.  If you have a copy more than a couple
  297. months old, get the latest JPEG FAQ from the news.answers archive.
  298.  
  299.  
  300. [6A]  If you are looking for viewers, application programs, etc:
  301.  
  302. This section covers programs for the following kinds of systems:
  303.     X Windows, MS-DOS, Microsoft Windows, OS/2, Macintosh,
  304.     Amiga, Atari ST, Acorn Archimedes, NeXT.
  305. If you don't see what you want for your machine, check out the free JPEG
  306. source code described in section 6B.  Assuming you have a C compiler and at
  307. least a little knowledge of compiling C programs, you should be able to
  308. prepare JPEG conversion programs from the source code.  You'll also need a
  309. viewer program.  If your display is 8 bits or less, any GIF viewer will do
  310. fine; if you have a display with more color capability, try to find a viewer
  311. that can read Targa or PPM 24-bit image files.
  312.  
  313. Note that this list concentrates on free and shareware programs that you can
  314. obtain over Internet; but a few commercial programs are listed too.  If you
  315. choose a commercial JPEG product, make sure that it can handle the Usenet-
  316. standard JFIF file format, or you won't be able to exchange images with
  317. anyone else.  (See section 10 if you want to know more about file formats.)
  318.  
  319.  
  320. X Windows:
  321.  
  322. XV (shareware, $25) is an excellent viewer for JPEG, GIF, and many other
  323. image formats.  It can also do format conversion and some simple image
  324. manipulations.  It's available for FTP from ftp.cis.upenn.edu (130.91.6.8),
  325. file pub/xv/xv-3.00a.tar.Z.  Version 3.00 is a major upgrade with support
  326. for 24-bit displays and many other improvements; however, it is brand new
  327. and still has some bugs lurking.  If you prefer not to be on the bleeding
  328. edge, stick with version 2.21, available from the same place.  Note that
  329. version 2.21 is not a good choice if you have a 24-bit display (you'll get
  330. only 8-bit color), nor is it good for converting 24-bit images to JPEG.
  331. But 2.21 works fine for converting GIF and other 8-bit images to JPEG.
  332. CAUTIONS:
  333. * with version 3.0, if you have an 8-bit display then you need to "lock
  334.   8-bit mode" to get decent display of JPEG images.  (But do NOT do this
  335.   if you intend to resave the image, because it'll be written from the
  336.   8-bit version, thus costing you image quality.)
  337. * with version 2.21, you need to check the "save at normal size" checkbox
  338.   when saving a JPEG file, or the file will be blurry.
  339. Both of these workarounds can be set up in your .Xdefaults file.
  340.  
  341. Another good choice for X Windows is John Cristy's free ImageMagick package,
  342. available from ftp.x.org (198.112.44.100), file
  343. contrib/applications/ImageMagick/ImageMagick-3.4.tar.gz.  This package
  344. handles many image processing and conversion tasks.  The ImageMagick viewer
  345. handles 24-bit displays correctly; for colormapped displays, it does better
  346. (though slower) color quantization than XV or the basic IJG JPEG software.
  347. The current version is 3.4.
  348.  
  349. Both of the above are large, complex packages.  If you just want a simple
  350. image viewer, try xloadimage or xli.  xloadimage views and converts many
  351. image file types including JPEG.  Version 4.1 has better JPEG support than
  352. prior versions and is easier to install.  xloadimage is free and available
  353. from ftp.x.org, file R5contrib/xloadimage.4.1.tar.gz.  xli is a variant
  354. version of xloadimage; xli is slightly better as an interactive viewer, but
  355. it can't be used as a converter, and it supports fewer file formats.  xli is
  356. also free and available from ftp.x.org:/contrib/applications/xli.1.16.tar.gz.
  357.  
  358. If you want a command-line JPEG conversion program, see the IJG source code
  359. described in section 6B.  (This code is included as a subdirectory in most
  360. of the above-mentioned packages.)
  361.  
  362. MS-DOS:
  363.  
  364. This covers plain DOS; for Windows or OS/2 programs, see the next headings.
  365.  
  366. QPEG is the fastest noncommercial JPEG viewer I know of.  In exchange for
  367. speed, QPEG gives up some image quality, particularly on 256-or-less-color
  368. displays.  Its best feature is a really-fast small preview window, which is
  369. great for searching through lots of image files. Also views GIF,TGA,BMP,PCX.
  370. Requires 386-or-better CPU and VGA-or-better display card.  Shareware, $20.
  371. Current version is 1.5e, available from ftp.tu-clausthal.de (139.174.2.10),
  372. file pub/msdos/graphics/qpeg15e.zip.  Also available from Simtel archive
  373. sites (see NOTE below), file msdos/graphics/qpeg15e.zip.
  374.  
  375. DVPEG is a free viewer for JPEG, GIF, Targa, and PPM files.  The current
  376. version, 3.0l, is available by FTP from sunee.uwaterloo.ca (129.97.50.50),
  377. file pub/jpeg/viewers/dvpeg30l.zip.  (That's lower case l, not digit 1.)
  378. This is a good basic viewer that works on either 286 or 386/486 machines.
  379. The user interface is clunky but functional.  DVPEG is substantially
  380. faster than it used to be; on hi-color displays it is nearly as fast as
  381. QPEG.  On 8-bit displays, its two-pass quantization mode is slow but gives
  382. much better image quality than QPEG can manage.
  383.  
  384. Lesser-used DOS viewers include:
  385. * DISPLAY, alias DISP.  Has many nice image manipulation features including
  386.   contact-sheet generation.  User interface is much improved over versions
  387.   prior to 1.70, but installation is still a little tricky.  Requires 386
  388.   or better.  Current version is 1.85, available from nctuccca.edu.tw:
  389.   /PC/graphics/disp/disp185a.zip and disp185b.zip.  Freeware.
  390. * NVIEW.  Views JPEG and half a dozen other image formats.  Easy to use,
  391.   very easy to install.  Only moderately fast, but it has lots of options.
  392.   Supports hi-color and true-color modes on some cards, but not mine :-(.
  393.   Requires 386 or better.  Current version is 1.3, available from Simtel
  394.   archive sites (see NOTE below), file msdos/graphics/nview130.zip.
  395.   Shareware, $25.
  396. * ColorView for DOS.  This viewer's main advantage is easy installation.
  397.   Menu interface is spiffy-looking but I find it a bit clunky to use.
  398.   Does not require 386, should work with any display that has a VESA
  399.   driver.  Current version is 2.1, available from Simtel archive sites (see
  400.   NOTE below), file msdos/graphics/dcview21.zip.  Requires a VESA graphics
  401.   driver; if you don't have one, look in vesadrv2.zip or vesa-tsr.zip from
  402.   the same directory.  Shareware, $30.
  403.  
  404. DISRECOMMENDATION: The well-known GIF viewer CompuShow (CSHOW, recently
  405. renamed 2SHOW) supports JPEG, but CSHOW's JPEG implementation is crummy:
  406. it's much slower than any of the above viewers, and its image quality is
  407. poor except on hi-color displays.  Too bad ... it'd have been nice to see
  408. a good JPEG capability in CSHOW, especially since CSHOW supports pre-VGA
  409. displays and most of the above viewers don't.  Available from Simtel archive
  410. sites (see NOTE below), file msdos/gif/2show105.zip.  Shareware, $25.
  411.  
  412. Due to the remarkable variety of PC graphics hardware, any one of these
  413. viewers might not work on your particular machine.  If you can't get *any*
  414. of them to work, you'll need to use one of the following conversion programs
  415. to convert JPEG to GIF, then view with your favorite GIF viewer.  (If you
  416. have hi-color hardware, don't use GIF as the intermediate format; try to
  417. find a TARGA-capable viewer instead.  VPIC5.0 is reputed to do the right
  418. thing with hi-color displays.)
  419.  
  420. The free IJG JPEG converters are available from Simtel archive sites (see
  421. NOTE below), file msdos/graphics/jpeg5.zip (or jpeg5386.zip if you have a
  422. 386 or better CPU and extended memory).  These programs will convert JPEG to
  423. and from GIF, BMP, Targa, and PPM formats; they are DOS compilations of the
  424. free source code described in section 6B.
  425.  
  426. Handmade Software offers free JPEG<=>GIF conversion tools, GIF2JPG/JPG2GIF.
  427. These are slow and are limited to conversion to and from GIF format; in
  428. particular, they can't produce 24-bit color output from a JPEG.  The sole
  429. advantage of these tools is that they will read and write HSI's proprietary
  430. JPEG format as well as the Usenet-standard JFIF format.  Since HSI-format
  431. files are rather widespread on BBSes, this is a useful capability.  Version
  432. 2.0 of these tools is free (prior versions were shareware).  Get it from
  433. Simtel archive sites (see NOTE below), file msdos/graphics/gif2jpg2.zip.
  434. NOTE: do not use HSI format for files to be posted on Usenet, since it is
  435. not readable on non-PC platforms.
  436.  
  437. Handmade Software also has a shareware image conversion and manipulation
  438. package, Image Alchemy.  This will translate JPEG files (both JFIF and HSI
  439. formats) to and from many other image formats.  It can also display images.
  440. A demo version of Image Alchemy version 1.7 is available from Simtel archive
  441. sites (see NOTE below), file msdos/graphics/alch17.zip.
  442.  
  443. JPGINDEX is a useful tool for making indexes of JPEG image collections.
  444. Available from Simtel archive sites, file msdos/graphics/jpgidx13.zip.
  445.  
  446. NOTE ABOUT SIMTEL FILES:  The largest Internet collection of PC-related
  447. programs is the Simtel archives (named for the original archive site, now
  448. defunct).  The principal archive site for these files is oak.oakland.edu
  449. (141.210.10.117), which keeps Simtel files under /SimTel; so look in, eg,
  450. /SimTel/msdos/graphics.  There are many mirror sites which keep copies of the
  451. Simtel files; for quickest response you should use the mirror site closest to
  452. you.  Consult the periodic postings in comp.archives.msdos.announce to find
  453. your nearest mirror site.  If you have no FTP capability, the same postings
  454. will tell you how to retrieve Simtel files by e-mail.
  455.  
  456. Microsoft Windows:
  457.  
  458. LView Pro is a viewer/editor/converter for JPEG, GIF, BMP, and other formats.
  459. Version 1.8 is available from Simtel archive sites (see NOTE above), file
  460. msdos/windows3/lviewp18.zip.  Requires 386 or better CPU.  LView Pro offers
  461. a wide array of image editing functions and can load JPEGs in either
  462. fast/low-quality or slow/high-quality modes.  Shareware payment ($30) is
  463. required only for business usage or to obtain versions optimized for
  464. Win32s/NT, 486 or Pentium CPUs.
  465.  
  466. WinECJ is a fast, no-frills viewer with image quality noticeably worse than
  467. most other JPEG viewers.  (You can purchase a version with better image
  468. quality for AUD$30.)  Version 1.2 is free and available from Simtel archive
  469. sites (see NOTE above), file msdos/windows3/winecj12.zip.  Requires Windows
  470. 3.1 and 256-or-more-colors mode.
  471.  
  472. WinJPEG (shareware, $25) displays JPEG,GIF,Targa,TIFF,PCX, and BMP files;
  473. it can write all of these formats too, so it can be used as a converter.
  474. It has some other nifty features including screen capture, color-balance
  475. adjustment, and slideshow.  The current version is 2.65, available from
  476. Simtel sites (see NOTE above), file msdos/windows3/winjp265.zip.  (This is
  477. a 286-compatible version; if you register, you'll get the 386-and-up
  478. version, which is roughly twice as fast.)
  479.  
  480. Some people prefer Paint Shop Pro.  It's not very impressive as just a JPEG
  481. viewer (especially since image quality is not very good on 8-bit displays),
  482. but it has lots of image manipulation features.  Shareware, $69.  Current
  483. version is 2.00, available from ftp.cica.indiana.edu, file
  484. pub/pc/win3/desktop/pspro200.zip.
  485.  
  486. QPEG and DVPEG (see DOS heading) work under Windows, but only in full-screen
  487. mode, not in a window.  Also note that you can run the DOS conversion
  488. programs described earlier inside a Windows DOS window.
  489.  
  490. OS/2:
  491.  
  492. The following files are available from ftp-os2.cdrom.com (192.153.46.2):
  493.  
  494. os2/2_x/graphics/jovw122b.zip
  495.     JoeView 1.22b: free JPEG/GIF/BMP/PCX/TIFF viewer.
  496. os2/2_x/graphics/pmjpg163.zip
  497.     PMJPEG 1.63: OS/2 2.x port of WinJPEG, a popular viewer/converter for
  498.     Windows (see description in Windows section).  Shareware, $20.
  499. os2/2_x/graphics/pmvu86b.zip
  500.     PMView 0.86b: JPEG/GIF/BMP/Targa/PCX viewer.  GIF viewing very fast,
  501.     JPEG viewing roughly the same speed as the above two programs.  Has
  502.     image manipulation & slideshow functions.  Shareware, $35.
  503. os2/2_x/graphics/imgarc13.zip
  504.     Image Archiver 1.03: image conversion/viewing with PM graphical interface.
  505.     Strong on conversion functions, viewing is a bit weaker.  Shareware, $15.
  506. os2/2_x/graphics/jpegv4.zip
  507.     32-bit version of free IJG conversion programs, version 4.
  508. os2/all/graphics/jpeg4_16.zip
  509.     16-bit version of same, for OS/2 1.x.
  510.  
  511. All of the OS/2 viewers require Palette Manager for best display quality.
  512.  
  513. Macintosh:
  514.  
  515. Most Mac JPEG programs rely on Apple's JPEG implementation, which is part of
  516. the QuickTime system extension; so you need to have QuickTime installed.
  517. To use QuickTime, you need a 68020 or better CPU and you need to be running
  518. System 6.0.7 or later.  (If you're running System 6, you must also install
  519. the 32-bit QuickDraw extension; it is built-in on System 7.)  The latest
  520. version of QuickTime is 1.6.1, available by FTP from ftp.apple.com, file
  521. dts/mac/sys.soft/quicktime/quicktime-1-6-1.hqx.
  522.  
  523. Mac users should keep in mind that QuickTime's JPEG format, PICT/JPEG, is
  524. not the same as the Usenet-standard JFIF JPEG format.  (See section 10 for
  525. details.)  If you post images on Usenet, make sure they are in JFIF format.
  526. Most of the programs mentioned here can handle either format.
  527.  
  528. The two major Internet sites for Mac software are sumex-aim.stanford.edu and
  529. mac.archive.umich.edu.  Unfortunately they are both very busy, so you may
  530. have better luck getting files from a mirror site.  See "Introductory
  531. Macintosh Frequently Asked Questions" in the comp.sys.mac.* newsgroups for
  532. the current locations of mirrors.
  533.  
  534. JPEGView is an excellent free program for viewing JFIF, PICT/JPEG, GIF, TIFF,
  535. and other image files.  It can convert between the two JPEG formats and can
  536. create preview images for files.  The current version is 3.3, available from
  537. sumex-aim.stanford.edu:/info-mac/grf/util/jpeg-view-33.hqx.  Requires System
  538. 7; QuickTime is optional.  JPEGView usually produces the best color image
  539. quality of all the currently available Mac JPEG viewers, and it needs much
  540. less memory to view large images than most other Mac viewers.  Given a large
  541. image, JPEGView automatically scales it down to fit on the screen, rather
  542. than presenting scroll bars like most other viewers.  (You can zoom in on any
  543. desired portion, though.)  Some people like this behavior, some don't.
  544. Overall, JPEGView's user interface is very well thought out.
  545.  
  546. GIFConverter, a shareware ($40) image viewer/editor/converter, supports JFIF,
  547. PICT/JPEG, GIF, and many other image formats.  Current version is 2.3.7,
  548. mac.archive.umich.edu:/mac/graphics/graphicsutil/gifconverter2.37.cpt.hqx.
  549. Requires System 6.0.5 or later.  GIFConverter is not better than JPEGView as
  550. a plain JPEG/GIF viewer, but it has much more extensive image manipulation
  551. and format conversion capabilities.  Also, GIFConverter can load and save
  552. JFIF images *without* QuickTime, so it is your best bet if your machine is
  553. too old to run QuickTime.  (But it's faster with QuickTime.)  Hint: if
  554. GIFConverter runs out of memory while loading a large JPEG, try converting
  555. the file to GIF with JPEG Convert, then viewing the GIF version.
  556.  
  557. A competitor to GIFConverter is GraphicConverter, also shareware ($35).
  558. Current version is 2.02, available at
  559. mac.archive.umich.edu:/mac/graphics/graphicsutil/graphicconverter2.02.cpt.hqx.
  560. Requires System 7 and QuickTime to handle JPEG.  GraphicConverter has even
  561. more functionality than GIFConverter, but is correspondingly larger.  Worth
  562. checking out if you want to manipulate images, not just look at them.
  563.  
  564. JPEG Convert, a Mac version of the free IJG JPEG conversion utilities, is
  565. available at sumex-aim.stanford.edu:/info-mac/app/jpeg-convert-10.hqx.
  566. This will run on any Mac, but it only does file conversion, not viewing.
  567. You can use it in conjunction with any GIF viewer.
  568.  
  569. Storm Technology's Picture Decompress is a free JPEG viewer/converter.
  570. This rather old program is inferior to the above programs in many ways, but
  571. it will run without System 7 or QuickTime, so you may be forced to use it on
  572. older systems.  (It does need 32-bit QuickDraw, so really old machines can't
  573. use it.)  File sumex-aim.stanford.edu:/info-mac/app/picture-decompress-201.hqx.
  574.  
  575. If your machine is too old to run 32-bit QuickDraw (a Mac Plus for instance),
  576. GIFConverter is your only choice for single-program JPEG viewing.  If you
  577. don't want to pay for GIFConverter, use JPEG Convert and a free GIF viewer.
  578.  
  579. More and more commercial Mac applications are supporting JPEG, although not
  580. all can deal with the Usenet-standard JFIF format.  Adobe Photoshop, version
  581. 2.0.1 or later, can read and write JFIF-format JPEG files.  (In 2.0.1, use
  582. the JPEG plug-in on the Acquire menu; 2.5 and later handle JPEG the same as
  583. other file types.)  You must set the file type code of a downloaded JPEG file
  584. to 'JPEG' to allow Photoshop to recognize it.
  585.  
  586. IMPORTANT HINT: if you use Fetch to retrieve files by FTP, add ".jpg" to its
  587. list of binary file types under Customize/Suffix Mapping.  Otherwise Fetch's
  588. "automatic" retrieval mode will retrieve a JPEG in text mode, thus corrupting
  589. the image.
  590.  
  591. Amiga:
  592.  
  593. Most programs listed in this section are available from "AmiNet" archive
  594. sites.  The master AmiNet site is wuarchive.wustl.edu (128.252.135.4), but
  595. there are many mirror sites and you should try to use the closest one.
  596.  
  597. Osma Ahvenlampi posted a good review of Amiga picture viewers in
  598. comp.sys.amiga.reviews in March 1994.  You can retrieve it from math.uh.edu,
  599. pub/Amiga/comp.sys.amiga.reviews/software/graphics/PictureViewerSurvey_2.
  600. Opinions here are mostly stolen from his article.
  601.  
  602. FastJPEG is a free JPEG viewer; it's fast and has good image quality, but it
  603. doesn't view any formats except JPEG.  Version 1.10 is even faster than the
  604. original, and it works with grayscale JPEGs now.  Available from Aminet
  605. sites, file pub/aminet/gfx/show/FastJPEG_1.10.lha.
  606.  
  607. PPShow is a very good free JPEG/GIF/ILBM/ANIM/Datatype viewer.  Version 4.0
  608. is available from Aminet sites, file pub/aminet/gfx/show/PPShow40.lha.  For
  609. viewing JPEGs it is a little slower than FastJPEG, and image quality is not
  610. as good (particularly on non-AGA machines); but if you want to use just one
  611. viewer, PPShow is the one.
  612.  
  613. HamLab Plus is an excellent JPEG viewer/converter, as well as being a
  614. general image manipulation tool.  It's cheap (shareware, $20) and can read
  615. several formats besides JPEG.  The current version is 2.0.8.  A demo version
  616. is available from AmiNet sites, file pub/aminet/gfx/edit/hamlab208d.lha.
  617. The demo version will crop images larger than 512x512, but it is otherwise
  618. fully functional.
  619.  
  620. Rend24 (shareware, $30) is an image renderer that can display JPEG, ILBM,
  621. and GIF images.  The program can be used to create animations, even
  622. capturing frames on-the-fly from rendering packages like Lightwave.
  623. The current version is 1.05, available from AmiNet sites, file
  624. pub/aminet/gfx/aga/rend105.lha.
  625.  
  626. Viewtek is a free JPEG/ILBM/GIF/ANIM viewer.  The current version is 2.1,
  627. available from AmiNet sites, file pub/aminet/gfx/show/ViewTEK21.lha.  This
  628. is reported to be a considerable improvement over 2.0 (which was actually a
  629. very buggy beta version).  Viewtek used to be the best free JPEG viewer for
  630. Amiga, but it now faces stiff competition from FastJPEG and PPShow.  The
  631. choice depends on your display hardware and personal preferences.  In
  632. particular, Viewtek is said to have poor display quality on ECS machines.
  633.  
  634. The free IJG JPEG software is available compiled for Amigas from AmiNet
  635. sites, file pub/aminet/gfx/conv/jpegv5bin.lha.  These programs convert
  636. JPEG to/from PPM,GIF,BMP,Targa formats.
  637.  
  638. If you're willing to spend real money, there are several commercial packages
  639. that support JPEG.  Well regarded products include CineMorph (from Great
  640. Valley Products), ImageFX (ditto), Art Department Professional or ADPro
  641. (ASDG Inc), and ImageMaster (Black Belt Systems).
  642.  
  643. The Amiga world is heavily infested with quick-and-dirty JPEG programs, many
  644. based on an ancient beta-test version of the free IJG JPEG software (thanks
  645. to a certain magazine that published same on its disk-of-the-month, without
  646. so much as notifying the authors).  Among these are "AugJPEG", "NewAmyJPEG",
  647. "VJPEG", and probably others I have not even heard of.  In my opinion,
  648. anything older than IJG version 3 (March 1992) is not worth the disk space
  649. it's stored on; if you have such a program, trash it and get something newer.
  650.  
  651. Atari ST:
  652.  
  653. GEM-View (shareware, $26) displays JPEG, GIF, and other image formats.
  654. Current version is 2.48, available from atari.archive.umich.edu, file
  655. /atari/Graphics/Gemview/gview248.lzh.  This is a well regarded viewer.
  656. The English documentation tends to be a few versions behind, though.
  657.  
  658. The free IJG JPEG software is available compiled for Atari ST/TT/etc
  659. from atari.archive.umich.edu, file /atari/Graphics/jpeg4bin.zoo.
  660. These programs convert JPEG to/from PPM, GIF, Targa formats.
  661.  
  662. For monochrome ST monitors, try MGIF, which manages to achieve four-level
  663. gray-scale effect by flickering.  Version 4.2 loads JPEG files much faster
  664. than 4.1 did.  Available from atari.archive.umich.edu, file
  665. /atari/Graphics/mgif42b.zoo.
  666.  
  667. Acorn Archimedes:
  668.  
  669. The Acorn archive at micros.hensa.ac.uk (148.88.8.84) contains several
  670. JPEG-capable programs.  Read the file /micros/arch/riscos/index for
  671. retrieval instructions.  Recommended archive entries include:
  672. a022 Translator 7.18: image file format converter (shareware)
  673. b008 FYEO 2.01: For Your Eyes Only, fast JPEG/GIF image viewer (shareware)
  674. a110 JPEG 5.00: IJG v5 software (JPEG<=>PPM,GIF,Targa) w/ desktop front end
  675.  
  676. !ChangeFSI, supplied with RISC OS 3 version 3.10, can convert from and view
  677. JPEG JFIF format.  Provision is also made to convert images to JPEG,
  678. although this must be done from the CLI rather than by double-clicking.
  679.  
  680. There's also a commercial product called !JPEG which provides JPEG read/write
  681. functionality and direct JPEG viewing, as well as a host of other image
  682. format conversion and processing options.  Contact: DT Software, FREEPOST,
  683. Cambridge, UK.  Tel: 0223 841099.
  684.  
  685. NeXT:
  686.  
  687. OmniImageFilter is a filter package that converts NeXTStep TIFF to and from
  688. about 30 image formats.  It reads JPEG but does not write it.  It works with
  689. most NeXTStep programs that handle drag-and-drop.  OmniImage is a simple
  690. image viewer that uses the filter package.  Both are free.  Available from
  691. ftp.omnigroup.com:/pub/software/OmniImageFilter-3.0.pkg.tar and
  692. ftp.omnigroup.com:/pub/software/OmniImage-3.0.1.pkg.tar.
  693.  
  694. ImageViewer is a PD utility that displays images and can do some format
  695. conversions.  The current version reads JPEG but does not write it.
  696. ImageViewer is available from the NeXT archives at sonata.cc.purdue.edu and
  697. cs.orst.edu, file pub/next/3.0/bin/ImageViewer0.9i.tar.Z.  Note that there
  698. is an older version floating around that does not support JPEG.
  699.  
  700. NeXTStep includes built-in support for TIFF/JPEG, but not for the
  701. Usenet-standard JFIF format.  Be warned that the TIFF/JPEG standard is
  702. likely to change away from the flavor currently produced by NeXTStep,
  703. so compatibility with other platforms is doubtful.
  704.  
  705.  
  706. [6B]  If you are looking for source code to work with:
  707.  
  708. Free, portable C code for JPEG compression is available from the Independent
  709. JPEG Group, which I lead.  A package containing our source code,
  710. documentation, and some small test files is available from ftp.uu.net
  711. (192.48.96.9) in directory /graphics/jpeg.  The current release is v5,
  712. file jpegsrc.v5.tar.gz.  You can retrieve this file by FTP or UUCP.
  713. If you are on a PC and don't know how to cope with .tar.gz format, you may
  714. prefer ZIP format, which you can find at Simtel archive sites (see NOTE
  715. above), file msdos/graphics/jpegsrc5.zip.  On CompuServe, see the
  716. GRAPHSUPPORT forum (GO GRAPHSUP), library 15, file jpsrc5.zip.
  717.  
  718. The IJG code includes a reusable JPEG compression/decompression library,
  719. plus sample applications "cjpeg" and "djpeg", which perform conversion
  720. between JPEG JFIF format and image files in PPM/PGM (PBMPLUS), GIF, BMP,
  721. Utah RLE, and Targa formats.  Two small applications "wrjpgcom" and
  722. "rdjpgcom" insert and extract textual comments in JFIF files.
  723. The package is highly portable; it has been used successfully on many
  724. machines ranging from Apple IIs to Crays.
  725.  
  726. We have released this software for both noncommercial and commercial use.
  727. Companies are welcome to use it as the basis for JPEG-related products.
  728. We do not ask a royalty, although we do ask for an acknowledgement in
  729. product literature (see the README file in the distribution for details).
  730. We hope to make this software industrial-quality --- although, as with
  731. anything that's free, we offer no warranty and accept no liability.
  732.  
  733. The Independent JPEG Group is a volunteer organization; if you'd like to
  734. contribute to improving our software, you are welcome to join.
  735.  
  736.  
  737. A different free JPEG implementation, written by the PVRG group at Stanford,
  738. is available from havefun.stanford.edu in directory pub/jpeg.  This program
  739. is designed for research and experimentation rather than production use;
  740. it is slower, harder to use, and less portable than the IJG code, but it
  741. implements a larger subset of the JPEG standard.
  742.  
  743.  
  744. [7]  What's all this hoopla about color quantization?
  745.  
  746. Most people don't have full-color (24 bit per pixel) display hardware.
  747. Typical display hardware stores 8 or fewer bits per pixel, so it can display
  748. 256 or fewer distinct colors at a time.  To display a full-color image, the
  749. computer must choose an appropriate set of representative colors and map the
  750. image into these colors.  This process is called "color quantization".
  751. (This is something of a misnomer; "color selection" or "color reduction"
  752. would be a better term.  We're stuck with the standard usage though.)
  753.  
  754. Clearly, color quantization is a lossy process.  It turns out that for most
  755. images, the details of the color quantization algorithm have *much* more
  756. impact on the final image quality than do any errors introduced by JPEG
  757. itself (except at the very lowest JPEG quality settings).  Making a good
  758. color quantization algorithm is a black art, and no single algorithm is best
  759. for all images.
  760.  
  761. Since JPEG is a full-color format, converting a color JPEG image for display
  762. on 8-bit-or-less hardware requires color quantization.  The speed and image
  763. quality of a JPEG viewer running on such hardware are largely determined by
  764. its quantization algorithm.  You'll see great variation in image quality
  765. among viewers on 8-bit displays, much more than occurs on 24-bit displays.
  766.  
  767. On the other hand, a GIF image has already been quantized to 256 or fewer
  768. colors.  (A GIF *does* have a specific number of colors in its palette, and
  769. the format doesn't allow more than 256 palette entries.)  GIF has the
  770. advantage that the image maker precomputes the color quantization, so
  771. viewers don't have to; this is one of the things that make GIF viewers
  772. faster than JPEG viewers.  But this is also the *disadvantage* of GIF:
  773. you're stuck with the maker's quantization.  If the maker quantized to a
  774. different number of colors than what you can display, you'll either waste
  775. display capability or have to quantize again to further reduce the number of
  776. colors (which results in much poorer image quality than if you had quantized
  777. once from a full-color image).  Furthermore, if the maker didn't use a
  778. high-quality color quantization algorithm, you're out of luck --- the image
  779. is ruined.
  780.  
  781. For this reason, JPEG promises significantly better image quality than GIF
  782. for all users whose machines don't match the image maker's display hardware.
  783. JPEG's full color image can be quantized to precisely match the viewer's
  784. display hardware.  Furthermore, you will be able to take advantage of future
  785. improvements in quantization algorithms (there is a lot of active research
  786. in this area), or purchase better display hardware, to get a better view of
  787. JPEG images you already have.  With a GIF, you're stuck forevermore with
  788. what was sent.
  789.  
  790. A growing number of people have better-than-8-bit display hardware already:
  791. 15-bit "hi-color" PC displays, true 24-bit displays on workstations and
  792. Macintoshes, etc.  For these people, GIF is already obsolete, as it cannot
  793. represent an image to the full capabilities of their display.  JPEG images
  794. can drive these displays much more effectively.
  795.  
  796. In short, JPEG is an all-around better choice than GIF for representing
  797. photographic images in a machine-independent fashion.
  798.  
  799.  
  800. It's sometimes thought that a JPEG converted from a GIF shouldn't require
  801. color quantization.  This is false: even when you feed a 256-or-less-color
  802. GIF into JPEG, what comes out of the decompressor is not 256 colors, but
  803. thousands of colors.  This happens because JPEG's lossiness affects each
  804. pixel a little differently, so two pixels that started with identical colors
  805. will usually come out with slightly different colors.  Each original color
  806. gets "smeared" into a group of nearby colors.  Therefore quantization is
  807. always required to display a color JPEG on a colormapped display, regardless
  808. of the image source.
  809.  
  810. The same effect makes it nearly meaningless to talk about the number of
  811. colors used by a JPEG image.  Even if you tried to count the number of
  812. distinct pixel values, different JPEG decoders would give you different
  813. results because of roundoff error differences.  I occasionally see posted
  814. images described as "256-color JPEG".  This tells me that the poster
  815. (a) hasn't read this FAQ and (b) probably converted the JPEG from a GIF.
  816. JPEGs can be classified as color or gray-scale, but number of colors just
  817. isn't a useful concept for JPEG, any more than it is for a real photograph.
  818.  
  819.  
  820. [8]  What are some rules of thumb for converting GIF images to JPEG?
  821.  
  822. Converting GIF files to JPEG is a tricky business --- you are piling one set
  823. of limitations atop a quite different set, and the results can be awful.
  824. Certainly a JPEG made from a GIF will never be as good as a JPEG made from
  825. true 24-bit color data.  But if what you've got is GIFs, and you need to
  826. save space, here are some hints for getting the best results.
  827.  
  828. With care and a clean source image, it's often possible to make a JPEG of
  829. quality equivalent to the GIF.  This does *not* mean that the JPEG looks
  830. identical to the GIF --- it probably won't on an 8-bit display, because the
  831. color quantization process used to display the JPEG won't exactly match the
  832. GIF's quantization.  (See section 7 for more about that.)  But given a good
  833. viewer, the JPEG will look as good as the GIF.  Some people claim that on
  834. 24-bit displays, a carefully converted JPEG can look better than the GIF
  835. source, because dither patterns have been eliminated.  (More about dithering
  836. in a moment.)
  837.  
  838. On the other hand, JPEG conversion *will* degrade an unsuitable image or one
  839. that is converted carelessly.  If you are not willing to take the amount of
  840. trouble suggested below, you're much better off leaving your GIF images
  841. alone.  Simply cranking the JPEG quality setting up to a very high value
  842. wastes space (which defeats the whole point of the exercise...) and some
  843. images will be degraded anyway.
  844.  
  845. The first rule is never to convert an image that's not appropriate for JPEG
  846. (see section 3 about that).  Large, high-visual-quality photographic images
  847. are usually the best material.  And they take up lots of space in GIF form,
  848. so they offer significant potential space savings.  (A good rule of thumb is
  849. not to bother converting any GIF that's much under 100 Kbytes; the potential
  850. space savings isn't worth the hassle.)
  851.  
  852. The second rule is to look at each JPEG, to make sure you are happy with it,
  853. before throwing away the corresponding GIF; this will give you a chance to
  854. re-do the conversion with a higher quality setting if necessary.  Also
  855. compare the file sizes --- if the image isn't suitable JPEG material, a JPEG
  856. file of reasonable quality may come out *larger* than the GIF.
  857.  
  858. The third rule is to get rid of the border.  Many people have developed
  859. an odd habit of putting a large single-color border around a GIF image.
  860. While useless, this is nearly free in terms of storage cost in GIF files.
  861. It is NOT free in JPEG files, either in storage space or in decoding time;
  862. and the sharp border boundary can create visible artifacts ("ghost" edges).
  863. Furthermore, when viewing a bordered JPEG on an 8-bit display, the quantizer
  864. will think the border color is important because there's so much of it, and
  865. hence will waste color palette entries on the border, thus actually reducing
  866. the displayed quality of the main part of the image!  So do yourself a favor
  867. and crop off any border before JPEGing.
  868.  
  869. Gray-scale images usually convert without much problem.  When using cjpeg,
  870. be sure to specify -gray.  (Otherwise, cjpeg treats a GIF as color data;
  871. this works but wastes space and time if the image is really only gray-scale.)
  872. Quality settings around the default (75) are usually fine.
  873.  
  874. Color images are much trickier.  Color GIFs of photographic images are
  875. usually "dithered" to fool your eye into seeing more than the 256 colors
  876. that GIF can actually store.  If you enlarge the image, you will find that
  877. adjacent pixels are often of significantly different colors; at normal size
  878. the eye averages these pixels together to produce the illusion of an
  879. intermediate color value.  The trouble with dithering is that, to JPEG, it
  880. looks like high-spatial-frequency color noise; and JPEG can't compress noise
  881. very well.  The resulting JPEG file is both larger and of lower image
  882. quality than what you would have gotten from JPEGing the original full color
  883. image (if you had it).  To get around this, you need to "smooth" the GIF
  884. image before compression.  Smoothing averages together nearby pixels, thus
  885. approximating the color that you thought you saw anyway, and in the process
  886. getting rid of the rapid color changes that give JPEG trouble.  Proper use
  887. of smoothing will both reduce the size of the compressed file and give you a
  888. better-looking output image than you'd get without smoothing.
  889.  
  890. With the IJG JPEG software (cjpeg or derived programs), a simple smoothing
  891. capability is built in.  Try "-smooth 10" or so when converting GIFs.
  892. Values of 10 to 25 seem to work well for high-quality GIFs.  Heavy-handed
  893. dithering may require larger smoothing factors.  (If you can see regular
  894. fine-scale patterns on the GIF image even without enlargement, then strong
  895. smoothing is definitely called for.)  Too large a smoothing factor will blur
  896. the output image, which you don't want.  If you are an image processing
  897. wizard, you can also do smoothing with a separate filtering program, but
  898. appropriate use of such tools is beyond the scope of this FAQ.
  899.  
  900. Quality settings around 85 (a bit higher than default) usually work well
  901. when converting color GIFs, assuming that you've picked a good smoothing
  902. factor.  You may need a higher quality setting if you can't hide the
  903. dithering pattern with a reasonable smoothing factor.  Really badly dithered
  904. GIFs are best left as GIFs.
  905.  
  906. Don't expect JPEG files converted from GIFs to be as small as those created
  907. directly from full-color originals.  You won't be able to smooth away all of
  908. the dithering noise (without blurring the image) and this noise wastes space.
  909. Typically, a good-quality converted JPEG will be 1/2 to 1/3rd the size of
  910. the GIF file, not 1/4th as suggested in section 4.  If the JPEG comes out
  911. much more than half the size of the GIF, this is a good sign that the image
  912. shouldn't be converted at all.
  913.  
  914. The upshot of all this is that "cjpeg -quality 85 -smooth 10" is probably a
  915. good starting point for converting color GIFs.  But if you care about the
  916. image, you'll want to check the results and maybe try a few other settings.
  917. Blindly converting a large GIF library at this or any other setting is a
  918. recipe for disaster.
  919.  
  920.  
  921. [9]  Does loss accumulate with repeated compression/decompression?
  922.  
  923. It would be nice if, having compressed an image with JPEG, you could
  924. decompress it, manipulate it (crop off a border, say), and recompress it
  925. without any further image degradation beyond what you lost initially.
  926. Unfortunately THIS IS NOT THE CASE.  In general, recompressing an altered
  927. image loses more information.  Hence it's important to minimize the number
  928. of generations of JPEG compression between initial and final versions of an
  929. image.
  930.  
  931. It turns out that if you decompress and recompress an image at the same
  932. quality setting first used, little or no further degradation occurs.
  933. (Counterintuitively, this works better the lower the quality setting.
  934. But you must use *exactly* the same setting, or all bets are off.)
  935. This means that you can make local modifications to a JPEG image without
  936. material degradation of other areas of the image.  The areas you change
  937. will degrade, though.
  938.  
  939. Unfortunately, cropping doesn't count as a local change!  JPEG processes
  940. the image in small blocks, and cropping usually moves the block boundaries,
  941. so that the image looks completely different to JPEG.  You can take
  942. advantage of the low-degradation behavior if you are careful to crop the
  943. top and left margins only by a multiple of the block size (typically 16
  944. pixels), so that the remaining blocks start in the same places.
  945.  
  946. The bottom line is that JPEG is a useful format for archival storage and
  947. transmission of images, but you don't want to use it as an intermediate
  948. format for sequences of image manipulation steps.  Use a lossless 24-bit
  949. format (PPM, RLE, TIFF, etc) while working on the image, then JPEG it when
  950. you are ready to file it away.  Aside from avoiding degradation, you will
  951. save a lot of compression/decompression time this way :-).
  952.  
  953.  
  954. [10]  Why all the argument about file formats?
  955.  
  956. Strictly speaking, JPEG refers only to a family of compression algorithms;
  957. it does *not* refer to a specific image file format.  The JPEG committee was
  958. prevented from defining a file format by turf wars within the international
  959. standards organizations.
  960.  
  961. Since we can't actually exchange images with anyone else unless we agree on
  962. a common file format, this leaves us with a problem.  In the absence of
  963. official standards, a number of JPEG program writers have just gone off to
  964. "do their own thing", and as a result their programs aren't compatible with
  965. anybody else's.
  966.  
  967. The closest thing we have to a standard JPEG format is some work that's been
  968. coordinated by people at C-Cube Microsystems.  They have defined two
  969. JPEG-based file formats:
  970.   * JFIF (JPEG File Interchange Format), a "low-end" format that transports
  971.     pixels and not much else.
  972.   * TIFF/JPEG, aka TIFF 6.0, an extension of the Aldus TIFF format.  TIFF is
  973.     a "high-end" format that will let you record just about everything you
  974.     ever wanted to know about an image, and a lot more besides :-).  TIFF
  975.     is a lot more complex than JFIF, and is generally less transportable,
  976.     because different vendors have often implemented slightly different
  977.     and incompatible subsets of TIFF.  It's not likely that adding JPEG to
  978.     the mix will do anything to improve this situation.
  979. Both of these formats were developed with input from all the major vendors
  980. of JPEG-related products; it's reasonably likely that future commercial
  981. products will adhere to one or both standards.
  982.  
  983. JFIF has emerged as the de-facto standard on Usenet.  JFIF is simpler than
  984. TIFF and is available now; the TIFF 6.0 spec for incorporating JPEG is not
  985. widely implemented, partly because it has some serious design flaws.  It is
  986. likely that the TIFF 6.0 JPEG section will be changed significantly before
  987. widespread adoption occurs.  Even when TIFF/JPEG is well defined, the JFIF
  988. format is likely to be a widely supported "lowest common denominator";
  989. TIFF/JPEG files may never be as transportable.
  990.  
  991. A particular case of wide interest is Apple's Macintosh QuickTime software.
  992. QuickTime uses a JFIF-compatible format wrapped inside the Mac-specific PICT
  993. structure.  Conversion between JFIF and PICT/JPEG is pretty straightforward,
  994. and several Mac programs are available to do it (see Mac portion of section
  995. 6A).  If you have an editor that handles binary files, you can even strip a
  996. PICT/JPEG file down to JFIF by hand; see section 11 for details.
  997.  
  998. Another particular case is Handmade Software's DOS programs (GIF2JPG/JPG2GIF
  999. and Image Alchemy).  These programs are capable of reading and writing JFIF
  1000. format.  By default, though, they write a proprietary format developed by
  1001. HSI.  This format is NOT readable by any non-HSI programs and should not be
  1002. used for Usenet postings.  Use the -j switch to get JFIF output.  (This
  1003. applies to old versions of these programs; the current releases emit JFIF
  1004. format by default.  You still should be careful not to post HSI-format
  1005. files, unless you want to get flamed by people on non-PC platforms.)
  1006.  
  1007.  
  1008. [11]  How do I recognize which file format I have, and what do I do about it?
  1009.  
  1010. If you have an alleged JPEG file that your software won't read, it's likely
  1011. to be HSI format or some other proprietary JPEG-based format.  You can tell
  1012. what you have by inspecting the first few bytes of the file:
  1013.  
  1014. 1.  A JFIF-standard file will start with the four bytes (hex) FF D8 FF E0,
  1015.     followed by two variable bytes (often hex 00 10), followed by 'JFIF'.
  1016.  
  1017. 2.  If you see FF D8 at the start, but not the 'JFIF' marker, you may have a
  1018.     "raw JPEG" file.  This is probably decodable as-is by JFIF software ---
  1019.     it's worth a try, anyway.
  1020.  
  1021. 3.  HSI files start with 'hsi1'.  You're out of luck unless you have HSI
  1022.     software.  Portions of the file may look like plain JPEG data, but they
  1023.     won't decompress properly with non-HSI programs.
  1024.  
  1025. 4.  A Macintosh PICT file, if JPEG-compressed, will have several hundred
  1026.     bytes of header (often 726 bytes, but not always) followed by JPEG data.
  1027.     Look for the 3-byte sequence (hex) FF D8 FF --- the text 'Photo - JPEG'
  1028.     will usually appear shortly before this header, and 'JFIF' or 'AppleMark'
  1029.     will usually appear shortly after it.  Strip off everything before the
  1030.     FF D8 FF and you should be able to decode the file.
  1031.  
  1032. 5.  Anything else: it's a proprietary format, or not JPEG at all.  If you are
  1033.     lucky, the file may consist of a header and a raw JPEG data stream.
  1034.     If you can identify the start of the JPEG data stream (look for FF D8),
  1035.     try stripping off everything before that.
  1036.  
  1037. In uuencoded Usenet postings, the characteristic JFIF pattern is
  1038.  
  1039.     "begin" line
  1040.     M_]C_X ...
  1041.  
  1042. whereas uuencoded HSI files will start with
  1043.  
  1044.     "begin" line
  1045.     M:'-I ...
  1046.  
  1047. If you learn to check for the former, you can save yourself the trouble of
  1048. downloading non-JFIF files.
  1049.  
  1050.  
  1051. [12]  How does JPEG work?
  1052.  
  1053. The buzz-words to know are chrominance subsampling, discrete cosine
  1054. transforms, coefficient quantization, and Huffman or arithmetic entropy
  1055. coding.  This article's too long already, so I'm not going to say more
  1056. than that here.  For technical information see the comp.compression FAQ,
  1057. which is available from the news.answers archive at rtfm.mit.edu, in files
  1058. /pub/usenet/news.answers/compression-faq/part[1-3].  If you need help in
  1059. using the news.answers archive, see the top of this article.
  1060.  
  1061. The comp.compression FAQ is also a good starting point for information on
  1062. other state-of-the-art image compression methods, such as wavelets and
  1063. fractals.  A quick comparison: wavelets are likely to be the basis of the
  1064. next generation of image-compression standards, but they are 5 to 10 years
  1065. behind JPEG in the standardization pipeline; as for fractals, it's very
  1066. difficult to separate real performance from hype.
  1067.  
  1068.  
  1069. [13]  Isn't there a lossless JPEG?
  1070.  
  1071. There's a great deal of confusion on this subject.  The JPEG committee did
  1072. define a truly lossless compression algorithm (i.e., one that guarantees the
  1073. final output is bit-for-bit identical to the original input).  However, this
  1074. lossless mode has almost nothing in common with the regular lossy JPEG
  1075. algorithm, and it offers much less compression.
  1076.  
  1077. Lossless JPEG typically compresses full-color data by around 2:1.  Lossless
  1078. JPEG works well only on continuous-tone images; it does not provide useful
  1079. compression of palette-color images or low-bit-depth images.  (The JBIG
  1080. standard is considered superior to lossless JPEG for images of less than 6
  1081. bits/sample.)
  1082.  
  1083. At present, very few implementations of lossless JPEG exist.  The PVRG code
  1084. mentioned in section 6B handles lossless JPEG.  Another free implementation
  1085. is available from ftp.cs.cornell.edu:/pub/multimed/ljpg.tar.Z; this is a
  1086. smaller program that handles *only* lossless JPEG.
  1087.  
  1088. Cranking a regular JPEG implementation up to its maximum quality setting
  1089. *does not* get you lossless storage.  Even at the maximum possible quality
  1090. setting, regular JPEG is not lossless, because it is subject to roundoff
  1091. errors in various calculations.  Roundoff errors are nearly always too small
  1092. to be seen, but they will accumulate if you put the image through multiple
  1093. cycles of compression.
  1094.  
  1095. Many implementations won't even let you get to the maximum possible setting,
  1096. because it's such an inefficient way to use regular JPEG.  With the IJG JPEG
  1097. software, for example, you have to say not only "-quality 100" but also
  1098. "-sample 1x1" to eliminate all deliberate loss of information.  The
  1099. resulting files are far larger and of only fractionally better quality than
  1100. files generated at more reasonable settings.  If you really need lossless
  1101. storage, don't try to approximate it with regular JPEG.
  1102.  
  1103.  
  1104. [14]  What about arithmetic coding?
  1105.  
  1106. The JPEG spec defines two different "back end" modules for the final output
  1107. of compressed data: either Huffman coding or arithmetic coding is allowed.
  1108. The choice has no impact on image quality, but arithmetic coding usually
  1109. produces a smaller compressed file.  On typical images, arithmetic coding
  1110. produces a file 5 to 10 percent smaller than Huffman coding.  (All the
  1111. file-size numbers previously cited are for Huffman coding.)
  1112.  
  1113. Unfortunately, the particular variant of arithmetic coding specified by the
  1114. JPEG standard is subject to patents owned by IBM, AT&T, and Mitsubishi.
  1115. Thus *you cannot legally use arithmetic coding* unless you obtain licenses
  1116. from these companies.  (The "fair use" doctrine allows people to implement
  1117. and test the algorithm, but actually storing any images with it is dubious
  1118. at best.)
  1119.  
  1120. At least in the short run, I recommend that people not worry about
  1121. arithmetic coding; the space savings isn't great enough to justify the
  1122. potential legal hassles.  In particular, arithmetic coding *should not*
  1123. be used for any images to be exchanged on Usenet.
  1124.  
  1125.  
  1126. [15]  Could an FPU speed up JPEG?  How about a DSP chip?
  1127.  
  1128. Since JPEG is so compute-intensive, many people suggest that using an
  1129. FPU chip (a math coprocessor) should speed it up.  This is not so.
  1130. Most production-quality JPEG programs use only integer arithmetic and so
  1131. they are unaffected by the presence or absence of floating-point hardware.
  1132.  
  1133. It is possible to save a few operations by doing the DCT step in floating
  1134. point.  On most PC-class machines, FP math is enough slower than integer
  1135. math that the overall speed is still much worse with FP.  Some high-priced
  1136. workstations and supercomputers have fast enough FP hardware to make an FP
  1137. DCT method be a win.
  1138.  
  1139. DSP (digital signal processing) chips are ideally suited for fast repetitive
  1140. integer arithmetic, so programming a DSP to do JPEG can yield significant
  1141. speedups.  DSPs are starting to be found as add-ons for PCs and small
  1142. workstations, so you can expect to see DSP-based JPEG programs popping up.
  1143.  
  1144.  
  1145. ---------------------
  1146.  
  1147. If you have more questions about JPEG in general or the IJG JPEG software
  1148. in particular, contact the Independent JPEG Group at jpeg-info@uunet.uu.net.
  1149.  
  1150. -- 
  1151.             tom lane
  1152.             organizer, Independent JPEG Group
  1153.             tgl@netcom.com or tgl@sss.pgh.pa.us
  1154.