|
Web pages use two main formats for images: GIF (pronounced jiff) and JPEG (or JPG, pronounced jay'·peg). Each format has its strengths and weaknesses, but both were designed to provide good image compression for faster download times. The GIF format is an indexed color format for images with between 2 and 256 unique colors. If an image has more than 256 colors they need to be reduced before saving. This is typically done within a graphics package by looking at which colors occur most frequently and rounding the other colors to the closest matching indexed color. Results can be improved by dithering. GIF is a lossless format, meaning no information is lost, no matter how many times you open and resave the image. These two attributes make GIF most suited to high contrast, low color count images. Examples include charts, graphs, text, and other computer produced images, as they have crisp lines (which the lossless format compresses well) and relatively low color counts. Additionally, GIF supports transparency and animations. Transparency allows one to create non-square graphics where the background of the web page will come through the transparent parts achieving a more polished look. Photos have far too many unique colors for GIF to handle. Even when the number of colors are reduced, photos tend to compress very poorly in GIF format, leading to very large files and poor visual quality. JPEG fixes these problems by supporting full RGB color and saves with lossy compression. Some information in the photo is discarded to achieve smaller file sizes. This data is generally imperceptible, as the format was designed around limitations in human perception. The chief drawback of JPEG is that it's lossy. Saving anything other than a photo (or photorealistic computer generated image) tends to produce very visible JPEG "artifacts." Images that would be perfect for GIF format (high contrast, crisp edges) will compress rather poorly in JPEG. JPEG does best with images that have gradual changes in color from one pixel to the next. That's why blurring an image slightly can produce better JPEG compression. Compare the following images saved in both formats and blown up to show the quality differences.
For the technically minded, file format specifications are available for GIF87a, GIF89a, GIF compression, and JPEG at the graphics file formats page. Sample image: Detail of triptych "The Garden of Earthly Delight", right wing ("Hell"), painted by Hieronymus Bosch in 1504. |