The magazine of the Melbourne PC User Group

Introduction to Image File Formats
Rick Gordon

Rick Gordon explains about digital camera images and tells you all you need to know to get the best out of your camera...

Digital cameras can generate pictures in a variety of sizes and formats. It's helpful to have an understanding of how an image will be used in order to make these choices. This article will provide the background information you need to help choose those best suited for your needs.

Image Size And Quality

What's In An Image?

An image generated by a digital camera is defined by the number of pixels it contains and by the method used to store those pixels. Each pixel contains the colour data for a single point within the image, analogous to a grain in silver based film. The colour data for a single pixel is made of RGB (Red Green Blue) components, each of which uses 8-bits, for a total of 24-bits, or 3 bytes, per pixel. (There are also formats using 16-bit components, or 48-bit pixels, but these are mostly used during scanning and image manipulation on the computer.)

The size of a digital image is measured in the total number of pixels. Usually this is expressed in terms of millions of pixels, Megapixels (Mp). This is calculated simply by multiplying the horizontal and vertical pixel dimensions. For example, a 2240x1448 image contains 3.3 Mp.

How Will an Image Be Used?

A selling point of a digital camera is almost always its Megapixel count. Having more pixels is often better, but they don't guarantee a good image. Lens quality, metering, and the algorithms used to process the captured image inside the camera also contribute greatly. But Megapixels is what most people latch onto - it's a nice easy number that can be used for comparison, and it does convey useful information; it's just not the whole story.

Depending upon your intended usage of the image, it's quite possible to have too many pixels! For example, if intended for a typical large screen display with a size of 1280x960, you really only need 1.2 Mp to fill the screen. So a 2 Mp camera is actually sufficient for images you don't intend to print.
 
Device Resolution and Image Size

The final use of an image should be the determining factor when deciding how large an image should be captured. For a full screen shot, a 2 Mp image size is sufficient to enable some cropping. But what if you want to print to paper? Then you have to know what the resolution of your output device is going to be. Once you know that, you just divide your pixel counts by that resolution to determine the maximum size you can print on that device (without manipulation.) Inkjet photo printers typically use a resolution of 240 pixels/inch (ppi) although some may suggest using 300 ppi. (Even the high resolution inkjet photo printers generally only use 240 ppi - because they use a combination of their 6 inks to form a single pixel on paper.)
 
For example, if you have a 2 Mp camera you may have an image with the dimension 1500x1300 pixels. If you wanted to print this to a typical inkjet photo printer, you would simply divide each dimension by 240, thus: 1500/240 = 6.25, 1300/240 = 5.42. So our 2 Mp camera can create pictures of approximately 6x5 inches. Rounding down, and leaving yourself some room to crop you can create standard-sized 6x4 images. Similarly, a 3.3 Mp image of dimensions 2240x1488 would provide 9.3 x 6.2 inches, while a 6 Mp, 3000x2000 image, generated by current, mid-range digital SLR cameras would provide 12.5 x 8.3 inches. As you can see, sometimes the relationship between horizontal and vertical dimensions, known as the aspect ratio, may also be a factor.

There are ways to increase the number of pixels within an image - they involve interpolating new pixels from existing ones and vary in their sophistication and effectiveness.

Compression and Quality

The previous discussion of image size assumed that the images were not actually compressed - they refer to the pixels available in the final image. In fact, images are usually compressed inside the camera. This allows the camera to store more images and enables it to capture images more rapidly. The reason is simply that the compression takes less time than it takes to write the uncompressed image to the camera's storage.

Lossless vs. Lossy

There are different methods of image compression, generally classified as either lossless or lossy. It's important to know what type you are dealing with in your images, because otherwise you may needlessly degrade their quality.

With lossless compression, all pixels of the image are saved in a form that takes less space, and from which all pixels can again be reconstructed. Thus the term "lossless" refers to the fact that nothing is lost when compressing and restoring the image. An image may be repeatedly compressed and expanded with no loss of data - like other digital copies each generation will appear the same as the original.

Lossy compression refers to any technique that results in a possible loss of data when the image is restored after being compressed. When applied only once, this type of compression is extremely efficient, with little visual degradation of the image. But if used repeatedly on an image as a result of editing and saving, it may result in a significant degradation of the original image. This degradation is visible in what are known as "artifacts" within the image. These are typically blotchy areas of colour, noise, etc.
 
LZW and JPEG Compression

There are only two forms of compression typically used on images captured by digital cameras: JPEG and LZW.

The LZW (Lempel-Ziv-Welch) compression algorithm was originally developed for use in disk controllers, and was also used in the indexed image files known as GIFs. It is a lossless compression commonly used to compress image data stored in TIFF files, but can be applied to any kind of data. Note that LZW compression is not usually done in camera - it is applied during processing on the computer.

The JPEG (Joint Photographic Experts Group) compression algorithm is designed to efficiently compress 24-bit colour images such as photographs, and is not as efficient with line art, cartoons and the like. It is a lossy compression scheme, designed to exploit the sensitivity of the human eye to brightness, while discarding colour data to which the eye is less sensitive. It generally provides compression up to 10:1 without noticeable degradation, and can compress even to 100:1 with a noticeable loss in quality.
 
Note that digital cameras that offer image quality settings such as Basic, Normal and Fine these are making changes to the amount of JPEG compression applied to the images. One experiment worth doing with a digital camera is to determine whether a smaller image (in number of pixels) with less compression is lower quality than a larger image with greater compression. Typically this the case, as the larger number of pixels provides more image detail, but its worth checking with your own equipment.
 
Still Image Formats

JFIF/JPEG (.JPG)

JPEG File Interchange Format. These files contain compressed image data, and possibly some Metadata. The images use a lossy compression technique - the user and/or the camera select the levels. Usually, when coming from a camera, these files have Metadata attached - see discussion on EXIF. These images are typically a good compromise between quality and speed of storage. However, because the compression used is lossy, they should not be used for repeated editing; before you start editing them, save to one of the lossless formats listed here.

TIFF (.TIF)

Tagged Image File Format, a standard way of storing image data in a file. TIFF provides a set of "tags" that define the information contained in the file. Generally, the image data stored in a TIFF file is not compressed, although if it is, it's often done using LZW compression which is not lossy. It makes a good format for storing edited images destined for high quality printing, as well as a non- proprietary storage format for edited images. These images do tend to be larger, so that if generated by a camera they take longer to write to its storage.
 
RAW

This is the format generated by the camera before being converted into RGB data. Due to the way the CCD operates in the camera, this typically contains 12-bit pixels that are then processed into the standard 24-bit RGB data shared by other formats. The advantage of this format comes with the ability to fine tune the image entirely on the computer. These images are usually only accessible with a vendor supplied program or plug-in, although there are a few 3rd-party applications that support them. This format is usually only found on the higher end cameras, but if you really want ultimate control over the final image, it is the one to use.

PNG

Portable Network Graphics format. This is an extensible way to store image data. Although not usually generated by cameras, it is useful as a lossless way of storing and using images. It's portable and supported by the modern Web browsers.

EXIF Metadata 

EXIF (Exchangeable Image file Format) Metadata is a standard adopted by JEIDA, the Japanese manufacturers group. It provides a way for camera manufacturers to embed both standard and proprietary information about the image and the camera within the same file. It's usually attached to JPEG images, but can also be found in TIFF images created by some cameras. Standard fields would include: aperture, shutter speed, image size, colour space, metering mode, flash usage. Vendor-specific fields might include: lens focal length, user comment, custom colour balance, tonal adjustments, etc.

DCF

DCF (Design rule for Camera File system) is a standard adopted by JEIDA for the storage of images on external media such as flash cards. You can recognise a card with this configuration by the presence of a DCIM (Digital Camera IMages) directory at the top. Within that are directories corresponding to the numbered folders often visible within the camera, and within each one of those are the image files.
 
DPOF

Digital Print Order Format is another standard adopted by camera manufacturers, that provides an encoding of the images selected by the user, ostensibly for printing. Using this mechanism, a flash card can be inserted into a printer or a kiosk and have the selected images printed automatically. You can recognise this file on a DCF-formatted card by the presence of a MISC directory.

PhotoShop (.PSD)

PhotoShop file format is not usually generated by cameras, but can be selected as an option when saving an edited image from within PhotoShop. It is most useful while editing images before a final image is generated, as all of the PhotoShop options are saved in the file.

Video/Audio Formats

Some digital still cameras can record movies, typically only a few minutes, at a low size and frame rate. Some digital still cameras can also record audio data and associate it with an image file. The method of association is vendor-specific, but typically it's simply a file using the same filename but a different extension. The software used is then responsible for binding the two files in some way to allow them to be presented.

Audio Data: WAV and AIF

WAV and AIF are two different ways of encoding audio data. WAV has historically been more common on Windows, while AIF is more common on UNIX and Mac OS machines, but they are all supported on each platform.

Video data: MOV, MPG and AVI

Video data from a camera is usually stored as a QuickTime Movie (.MOV), an MPEG 1 file (.MPG) or an Audio Video Interleaved (.AVI). They all work on modern platforms but of course require editing software to do much with.

Summary

Given all these options, how to know which size and format to use? Here are the rules I usually apply when choosing:

  • I always shoot in the largest size available unless I'm running out of memory or I know I'm only shooting for Web use;
  • If I'm shooting fast action subjects and/or snapshots, I use JPEG compressed images - they're faster and smaller.
  • If I really didn't plan ahead and I'm running out of memory, I crank the compression up a notch, retaining a larger image size;
  • If I'm shooting stuff under questionable lighting (especially mixed light sources), or in studio, or just something where I want the highest quality possible (short of film) I use RAW format and post-process on the computer.
When editing images on the computer, the first thing I do is save a copy of the image in either TIFF or PSD (PhotoShop) format. This helps to preserve the original image and establishes a lossless format for the image file for later saves. Only when I'm finished editing do I generate another JPEG image, using a different filename from the original. This helps to prevent compression artefacts from further degrading the image, and again preserves the original image.

About the Author
Rick Gordon, rgordon@oz.net is a software developer based in Seattle, WA. Recent projects included developing the camera interfaces in the Adobe PhotoShop Album product, and image and colour management support in the Adobe SVG Viewer plug-in. Rick is an avid amateur photographer who shoots a lot less film these days, but still likes black-and-white traditional processes.


Reprinted from the March 2003 issue of PC Update, the magazine of Melbourne PC User Group, Australia

[ About Melbourne PC User Group ]