When capturing images, there are a number of choices you can make about compression ratios and file formats. Your choices determine image quality and the size of the files you create.
Image files are huge compared to many other types of computer files. For example, a low-resolution 640 x 480 image has 307,200 pixels. Since each pixel requires 24 bits (3 bytes) to store color information, a single image takes up about a megabyte of storage space. As the resolution increases, so does the file size. At a resolution of 1600 x 1200, each 24-bit picture takes up over 5.7 megabytes. To make image files smaller and more manageable, digital cameras use a process called compression. Compressing images not only let's you save more images on a camera's storage device, it also allows you to download, display, edit, and transmit them more quickly.
During compression, data that is duplicated or that has no value is eliminated or saved in a shorter form, greatly reducing a file's size. For example, if large areas of the sky are the same shade of blue, only the value for one pixel needs to be saved along with the locations of the other pixels with the same color. When the image is then edited or displayed, the compression process is
reversed. There are two forms of compression—lossless and lossy—and digital cameras use both forms.
- Lossless compression. When an image compressed with lossless compression is uncompressed, its image quality matches the original source—nothing is lost. Although lossless compression sounds ideal, it doesn't provide much compression and files remain quite large. For this reason, lossless compression is used mainly where detail is extremely important, as it is when planning to make large prints or use high-quality printing. Lossless compression is offered by some digital cameras in the form of TIFF and RAW file formats.
- Lossy compression. Because lossless compression isn't practical in many cases, all popular digital cameras offer a lossy compression (rhymes with "bossy"). This process degrades images to some degree and the more they're compressed, the more degraded they become. In many situations, such as posting images on the Web or making small to medium sized prints, the image degradation isn't obvious. However, if you enlarge an image enough, it will show. The most common lossy file format is JPEG.
You have a number of choices when it comes to file formats. All digital cameras store still images in the JPEG format, but some also let you select TIFF or CCD RAW. A forth format, GIF, has limited uses. Let's look at all four formats.
- JPEG, named after the Joint Photographic Experts Group and pronounced "jay-peg," is by far the most popular format for photographic images. In fact, most cameras save their images in this format unless you specify otherwise.
A JPEG image is stored using lossy compression and you can vary the amount of compression—perhaps to reduce files to 1/4, 1/8, or 1/16 their original size. This allows you to choose between lower compression and higher image quality or greater compression and poorer quality. Most cameras give you two or three choices equivalent to good, better, best although the names vary. JPEG compression is performed on blocks of pixels eight on a side. You can see these blocks when you use the highest levels of compression and then greatly enlarge the image.
- TIFF (Tag Image File Format) has been widely accepted as an image format. Because of its popularity in digital photography, the format has been revised to TIFF/EP (Tag Image File Format—Electronic Photography). TIFF/ EP may be stored by the camera in uncompressed form, or using JPEG compression. TIFF/EP image files are often stored in a "read-only" fashion to prevent accidental loss of important information contained within the file. This is why you sometimes can't delete them once they are on your computer without first turning off the file's read-only attribute.
- CCD RAW format stores the data directly from the image sensor without first processing it. This data contains everything captured by the camera. In addition to the digitized raw sensor data, the RAW format also records color and other information that is applied during processing to enhance color accuracy and other aspects of image quality. Instead of being processed in the camera, where computing power and work space is limited (imagine Scarlett O'Hara trying to change into a Civil War era ball gown in a small closet), the raw data is processed into a final image on a powerful desktop computer. The increased computing power and space to work in can make a significant difference in the results. You don't get the artifacts (image flaws) that sometimes appear in JPEG images. In addition, you can save the original raw data and process it with other software, or in different ways. This is unlike a JPEG image where data are permanently changed or deleted during processing in the camera and can never be recovered.
In addition to image quality, RAW files have other advantages. Their files are approximately 60% smaller than uncompressed TIFF files with the same number of pixels, and the time you have to wait between shots is shorter since processing time in the camera is shorter.
- GIF format was designed primarily for line art and supports only 256 colors (the other formats we've discussed support millions). These files are not created by any digital camera, but you can convert an image to this format in most photo-editing programs. Despite their color limitations, there are two reasons to use this format. First, you can designate one color as
transparent. When you do so, and place the image on a Web page, the background shows through the transparent color—usually the area around the subject. Second, you can create an animation with a series of GIF images using a shareware program such as GIF Construction Set. When the animated GIF is posted on the Web, the images are quickly displayed one after the other like frames in a movie.
Choosing a Format
If your camera lets you choose a file format and compression ratio you should always choose those that give you the highest quality. If you decide later that you can use a smaller image or greater compression, you can do so to a copy of the image using a photo-editing program. If you shoot the image at a lower quality setting, you can never really improve it much or get a large, sharp print if you want one. The only problem with this approach has to do with file sizes. The highest quality images can be 15 or more megabytes in size. These are almost impossible to send to anyone by e-mail and are slow to open, edit, and save on even a powerful desktop computer. In addition, when you shoot images of this quality you often have to wait a long time between shots because the camera is tied up processing the last image you took. Most photographers use a compromise and shoot in the highest quality JPEG format. Even these image files can be 2-5 megabytes in size on the latest cameras.
When you open an image to work on it, you should first save it so you are
working on a copy and preserving the original image unchanged. Save it in a loss-free format such as TIFF. Even better, your photo-editing program may have its own native format that preserves information that no other format will. Use this format while editing. If you want a specific format for the finished image, save a copy of it in that format as the final step. In particular, don't repeatedly close, open, and resave JPEG original images. Every time you open one of these files, and then save it again, the image is compressed. As you go through a series of saves and reopens, the image becomes more and more degraded—an image quality death spiral. (An image is compressed
only once during a single session, no matter how many times you save it, so save it frequently to avoid losing your edits). Also, when you save an image as a JPEG, the image on the screen won't show the effects of compression unless you close the file and then open the saved version.
Many digital photos end up on the Web or attached to e-mail, so they are viewed on the screen. For these purposes, small, heavily compressed JPEG files that are easy to view or send over the Internet are favored. For the highest quality printed images, TIFF or RAW formats should be used. RAW is
especially useful when accurate color rendition is essential.
The top photo is a TIFF image that hasn't been compressed. The bottom image is a JPEG image that has been repeatedly compressed.