Image Optimization
Choosing the Right Image Format
Three image file formats are reliably supported on the Web:
- Graphics Interchange Format (GIF)
GIF is the oldest of three file formats in use on the Web, and is typically used for images with large areas of flat color.
- Joint Photographic Experts Group (JPEG) File Interchange Format
As suggested by its name, the JPEG format is especially well-suited to photographs, and is supported by all digital still cameras. The JPEG format is also the only popular format that reliably supports embedded color profile data.
- Portable Network Graphics (PNG)
The PNG specification was drafted and approved by the W3C as a direct response to the technical and patent limitations of GIF. In fact, PNG is superior to GIF in nearly all respects except for one—Internet Explorer 6 does not support PNG alpha channels as a matter of course. This issue is discussed in Chapter 14.
A fourth format, called Scalable Vector Graphics (SVG), is actually a dialect of XML. While SVG offers a number of impressive features—and, like PNG, is a categorically open format—it’s incompletely supported by common web browsers (and in Internet Explorer’s case, not at all).
If an image is a line drawing, or contains large areas of flat color, it should be saved in GIF or PNG format. PNG is preferable if more than one level of transparency (i.e., on or off) is required.
Photos should always be saved in JPEG format. Applying JFIF encoding to nonphotorealistic images is a trickier proposition, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access