Home   Back to Tutorials


Image File Formats

By T. Zinneman

The format of a file defines the way the data is structured and saved to your disk. Many companies that develop graphics programs also develop their own proprietary format for saving their graphics/image files. Literally hundreds of different file formats have been developed during the past 20 years. Thankfully, only a dozen or so formats are widely supported by the current generation of image editing programs. Of these, four or five are quite popular and are considered to be standardized formats.

Because raw image files are quite large, some type of compression is generally used for storage. There are two types of data compression algorithms, lossless and lossy. Lossless compression maintains data integrity, i.e., after compression and decompression, the resulting image is exactly the same as the initial uncompressed file. Lossy compression does not maintain data integrity, i.e., the uncompressed image is similar to, but not exactly the same as the initial image. There is a tradeoff between the amount of compression and the resulting quality of the image. Lossy compression methods provide a higher compression ratio, thus smaller file sizes, than lossless methods.

The Windows operating system and the applications that run under it use the three-letter file extension of a file name to determine the format of the file. Following are extensions of the most widely used image file formats: .tif, .jpg, .gif, and .png. Letís examine each of these image formats in a little more detail.

The Tagged Image File Format (.tif) was developed by Aldus Corp in the 1980ís and later received support from Microsoft Corp. This format supports monochrome, 8-bit grayscale, and 24-bit color images as well as a variety of other color settings. These files can exist in both the uncompressed or compressed (lossless) formats. Depending on the image, compression can reduce the file size by 5 to 50 percent. This format is used for saving high quality images and is great for saving images that you intend to edit more than once or import into a publishing application. A 2-megapixel image stored in the uncompressed .tif format requires approximately 6 Mbytes of storage space. This can be reduced to 3-4 Mbytes when compressed.

The most commonly used format for saving digital images is the JPEG (.jpg) format. This format is named after the Joint Photographic Experts Group, which developed the standard. The JPEG format uses a lossy data compression algorithm, which works as follows. The image data is examined in 8 x 8 blocks, that is, 64 pixels at a time. It averages the colors in the block and places that average in the upper left pixel. The other 63 pixels are assigned truncated values based on how closely they resemble the average color. If a pixel is close to the average, the algorithm changes it to the average. If the pixel is far from average, the color is adjusted to make it a closer match. The result is a dramatic savings in bytes stored in memory.

The JPEG algorithm allows the user to determine just how close is close. Up to 100 quality settings are provided. A high quality setting applies less compression, meaning fewer changes are applied to the group of 63 pixels in each block. By lowering the quality setting, more and more pixels in the block are changed, which reduces the file size, but also reduces the quality of the image. Some image editing/viewing programs allow the user to view in real-time, the affects of changing the quality of compression. This is quite useful when downsizing a file for an e-mail attachment. It permits the user to determine just how much compression can be applied before affecting the visible quality of the image. A 2-megapixel image (6 Mbytes) saved at a 90% quality factor will typically produce a file size around 400 Kbytes. A 30% quality factor will result in a file size of around 100 Kbytes or less.

If you open a JPEG image, edit it, and then save it to disk, the software reapplies JPEG compression, further degrading the quality of the image. If you intend to edit the image several times, itís best to save it in a lossless format, such as TIFF, to prevent further image degradation. Remember, when opening an image to view it, close it with the close command or the X in the upper right corner of the window. Do not use the save command to close it, because jpeg compression will be applied again.

The Joint Photographic Experts Group has released a new JPEG standard, known as JPEG 2000. It uses compression algorithms based on wavelet sampling, rather than discrete cosine transfer sampling used in the current algorithms. The new standard will produce more compressed images with less degradation than the current standard. However, because it uses a different sampling algorithm, it is not backward compatible. Thus, it will take some time before it becomes the defacto image compression standard.

The Graphics Interchange Format (.gif) was developed by Unisys Corp and Compuserve for transmitting graphical images over phone lines via modems. It uses lossless data compression. Although GIF images are limited to 8-bit (256) colors, each of these colors may be any one of 16 million available from a 24-bit color library. To communicate the colors, an index is included with each GIF file. For example, the index may specify that color 1 is dark red, color 2 is medium red, color 3 is light green, and so forth.

There are two GIF standards, 87a and 89a. The 89a version includes support for simple animation. The GIF format is suitable for images with few distinctive colors, such as those produced by graphic drawing or paint programs. It can also be used with high contrast photographs, particularly those that include text.

The Portable Network Graphics format (.png) is a relatively new format that combines the best of GIF and JPEG. It can work with 24-bit color images and uses a lossless compression technique. It also adapts its compression to the specific type of image being saved. Unfortunately, this format is not widely supported, but will eventually become more popular, probably replacing the GIF format.

In addition to the above system-independent formats, there are two system-dependent formats that you may encounter. Microsoft developed the Bitmap (.bmp) format to handle images at the Windows desktop level. Apple created the PICT format to serve the same purpose for the Mac operating system. Both of these are platform-specific formats.

Most image editing programs have their own native format. For example, .psd, is the native format used by Adobeís Photoshop. It saves layers, masks, paths, and other items forbidden by the standard formats such as JPEG and TIFF. There is nothing wrong with saving an image in your programís native format. However, if you want to import your image into another program or attach it to an e-mail message, youíll need to save a copy in one of the standardized formats.

 

T. Zinneman is a member of the Photo Adventures Camera Club. If you have any questions or comments, please send them to tzinneman@comcast.net.