
Discover the differences between the three main web graphic formats and learn the pros and cons of each format.

Discover the differences between the three main web graphic formats and learn the pros and cons of each format.
Here's a quick overview of the three main web graphic formats (we're excluding Flash here, since it requires a plug-in, though we agree it is becoming a fourth major format): GIF, JPEG, and PNG. We'll compare the three formats, then use and display actual images saved in those formats (images courtesy of PickleZone.com).
| GIF (Graphic Interchange Format) | JPEG (Joint Photographic Experts Group) | PNG - 8 & 24 (Portable Network Graphic) |
|---|---|---|
| Originally developed by CompuServe in the '80's, this format offers a maximum of 256 colors, is still used for simple animations, and is "lossless" -- does not introduce pixel noise into images. Web art books recommend this format to keep clean edges around illustrations & text -- though PNG offers the same advantage. | Professional photographers and programmers worked out this solution (early '90's) to incorporate millions of colors in an image with a range of compressed file sizes depending on how much quality you wish to retain -- the smaller the file, the lower the quality. | Developed in the late '90's to offer improvements on both GIF and JPEG formats, the 8 bit PNG offers a maximum of 256 colors, but with a wider range of transparency options*. 24 bit PNG, offers millions of colors, like JPEG, but cannot reduce file size as much as JPEG because this format uses "lossless" compression methods. |
{mostip image=tipon}Some transpareny options built into PNG formats are not implemented in Internet Explorer 6 or below. {/mostip}
{mostip image=note}Overview: At this time (mid 2000's) on the web, PNG-8 is a good choice for simpler images, while JPEG is still fine for photographs (remember you can increase the quality level), with PNG-24 available as another option with a larger file size, but lossless compression.{/mostip}
{mosimage title=Visual Comparisons: GIF, JPEG, & PNG Formats}
Even though we have noted these important perceptual limitations, it is still easy to see some of the differences image formats make on your web graphics.
Ok webmasters... which format would you select for this photograph, and why? Looks like JPEG wins here, since it clearly offers the better download speed, and the defects at the edges are not too apparent at the 100% screen size at which people normally view the image.
Good question. Take a look at the image below:
You can see definite decay in the image at the edges where the red arrows point, and also in the circled area, where extreme JPEG compression groups pixels in large square groups to save file size. Note that we've exaggerated the effect of JPEG compression by selecting "0" quality at the extreme low end of the scale -- a setting we would never use... except to learn exactly what JPEG compression is all about. Uh-oh, looks like we are stuck with some image decay using JPEG (true or false? read on for the answer).
Study the four images above, carefully (ideally on your own screen in photoshop, after first opening the accompanying tutorial file, then choosing Save for Web). While PNG-24 does render the image closest to the original, without introducing changes in how the pixels are displayed, it only cuts the file size by about 26%. While the upper right JPEG setting (Quality 35) cuts the file size to 2% of the original! However, some defects are apparent in the image due to the JPEG compression method. So do we opt for the PNG-24 format? No. Opt instead for a higher quality JPEG like the example at lower left above -- Quality level 60 (also called "high" quality in Photoshop). This image has much fewer compression defects, and still is 1/16th the size of the original, and a 10th the size of the PNG-24. Sure... it takes a long while to download at 56k -- but how much longer will a significant number of your audience be stuck at this slow modem speed (recent studies show that over 60% of homes in the US are connected via broadband service)?
{mostip image=tipon}Photographers... stop worrying about decay with JPEG format! Why? You can save your original in RAW, TIFF, or Photoshop format to remain faithful to what your camera captured. Then save a web version of the photograph at the highest quality JPEG your web visitors can stand. And... at 100% Quality, JPEG saves smaller files, without detectable defects -- at all.{/mostip}
Now, to lock in our learning, we'll look at two more graphic images and consider the different file formats.
{mospagebreak title=Gif, JPEG, & PNG Comparisons on a Background and Logo Image}
Though we ended up recommending a good quality JPEG for the photograph above, let's see what format works best for a logo (right), then a background image.
As web developers, we sometimes use an image like this at a small size and set it to repeat, or "tile", across or down a web page. Another option is to use the graphic large, and set it to not repeat using CSS controls, as a large background for an entire page. We'll take a look at file formats for two image sizes: for use as a repeating tile at 60 x 45 pixels and 72ppi, and as a large page background at 8 x 6 inches and 96 ppi.