Friday, April 23, 2010

Key File Formats

This section will list each of the important file formats available for use both with digital cameras and image editors, including a few that you should avoid when working with images. I'll discuss their advantages, disadvantages, and the types of image compression used.

JPEG

JPEG is the most common format used by digital cameras to store images, as it was designed specifically to reduce the file sizes of photographic-type images. JPEG allows dialing in a continuous range of quality/compression factors. In image editors, you'll find this range shown as a quality spectrum from, say 0 to 10 or 0 to 15. Sometimes, editors let you choose from Low, Medium, or High quality. Those are just different ways of telling the algorithm how much information to discard.

Digital cameras, on the other hand, usually lock you into a limited number of quality settings with names like Standard, Fine, Extra Fine, or Super Fine, and don't tell you exactly which JPEG quality settings those correspond to. The names for the quality settings aren't standardized, and a particular setting for one camera doesn't necessarily correspond to the same quality level with another camera. For example, Super Fine might be the highest lossy JPEG setting with one model and the lossless TIFF setting with another vendor's camera.

If you're concerned about image quality, you should probably use the best JPEG setting all the time, or alternate between that and the RAW setting. Your choice might hinge on how much storage space you have. When I'm photographing around the home where I have easy access to a computer, I use RAW. When I travel away from home, I switch to JPEG if I think I'm going to be taking a lot of pictures. If quality isn't critical, then use lower-quality JPEG settings with your camera. Figure 4.1 shows close-up views of two JPEG files, one with mild compression and the other with extremely high JPEG compression.

Figure 4.1. Mild compression (left) doesn't reduce image quality by much, but heavier compression (right) introduces visible artifacts.

JPEG 2000

JPEG 2000 is a relatively new file format, supported by Photoshop CS 2.0 and some other image editors, but not universally supported by the applications that we'd find the most useful: web browsers. At this time, no digital cameras produce files in this format. JPEG 2000 uses a compression scheme called wavelet compression (for roughly 20 percent smaller files), which provides better image quality, but still discards some information. JPEG 2000 files have extensions like .jpx, jpc, or .jp2.

JPEG 2000 offers the ability to download a lower resolution image first, so you can preview the image in your web browser and decide whether to continue to download the page. Whereas conventional JPEG works only with RGB images, this new version is compatible with RGB, L*a*b color, and CMYK (cyan, magenta, yellow, black) color models. It can also include color profile information, as well as informational tags such as the owner of the image. JPEG 2000 also offers a lossless compression mode, which reduces the file size by roughly 50 percent, while not discarding any information.

JPEG 2000 has a very cool feature called Region of Interest, which you can use to designate the most important parts of an image. When you've done that, image compression will be concentrated in other areas of the photo, preserving more detail in your Region of Interest. This feature is very easy to use. In Photoshop, just select the region you want to protect (Quick Mask mode works well) and use Selection > Save Selection to store the selection as an alpha channel. Then when you use Save As and choose the JPEG 2000 format, the dialog box that appears (shown in Figure 4.2) has an option for selecting which, if any, of the alpha channels you've stored should be used as the ROI.


Figure 4.2. Choose any of the alpha channels in your image as a Region of Interest when you save in JPEG 2000 format.

GIF

GIF, or Graphics Interchange Format, was developed back in the online dark ages (1987—before the public Internet) to exchange compressed graphics between different computer platforms. That's a bigger deal than you might think. In those days it was tricky to create image files on one computer that could be readily viewed on another computer, and with 300 to 1200 baud modems, even small image files could take many minutes to upload or download. The online service CompuServe was the first big user of the GIF format.

The GIF format converts images into files with a maximum of 256 colors. Few video cards could display more than 256 colors, anyway, in those days, so that sufficed. GIF achieves its small file size by first reducing the colors available in an image to 1 to 256 different hues, then squeezing the file further by applying LZW compression to the indexed color tables that remain. So, GIF can be considered both a lossy and lossless file format. It loses picture information when the number of colors is reduced (but if the number of colors in an image is already 256 hues or fewer, no colors are discarded), but the remaining information is preserved 100 percent.

GIF has some other features that are useful chiefly for web display, such as interlacing (which allows an image to be displayed progressively as it downloads), transparency (which makes it possible for a GIF image to show the page background in its transparent parts), and animation (several images embedded in one file and shown consecutively, like an animated cartoon).

Because it can handle no more than 256 colors, GIF is a poor choice for digital camera images (which look posterized when converted to 256 tones) and is best used for logos, dialog boxes, line art, charts, and other graphics that don't involve continuous tones. Its compression scheme works great with images that have few colors, producing files that can be even smaller than those afforded by JPEG. Figure 4.3 shows a full-color image that has been reduced to 256 colors.

Figure 4.3. Full-color images look posterized when reduced to 256 colors.

PNG

The PNG (Portable Network Graphics) format was designed as a replacement for GIF, because the compression algorithm used in GIF was patented by Unisys, and developers supporting the GIF format were theoretically required to pay Unisys a royalty. The patent expired in June, 2003 in the United States, and in Canada, Japan, and Europe in 2004, so royalties will be charged only in countries in which the patent has not fizzled out (in other words, virtually nowhere).

That leaves PNG, a format that never saw much favor, even further in limbo than it was before. Even though PNG has some advantages over GIF or even JPEG, it's unlikely to flourish in the future. PNG uses optimized preprocessing filters that improve lossless compression efficiency, particularly in 24-bit images. Unlike GIF, PNG can specify any combination of 256 colors for transparency, embed gamma values so the image displays well on both Macs and PCs (which use different gamma settings), and beat both GIF and TIFF for compressing images.

PCX

PCX is an early graphics file format established by Zsoft for its PC Paintbrush software. It supports 24-bit color, and provides decent lossless file compression, but is now used only as a backup format. I sometimes save files in PCX format when the recipient is having trouble reading my TIFF files. Unlike TIFF, PCX doesn't have a wide variety of options and is thus more "standardized" and compatible with a wider variety of software on Mac, PC, and Linux platforms.

No digital cameras use PCX, but most image-editing software supports it.

TIFF

TIFF, or Tagged-Image File Format, was designed in 1987 by Aldus (later acquired by Adobe along with Aldus' flagship product PageMaker) to be a standard format for exchange of image files. It's become that, and is even though it is supported by only a few digital cameras as a lossless file option. However, because TIFF supports many different configurations, you might find that one application can't read a TIFF file created by another. The name itself comes from the tags, or descriptors, that can be included in the header of the file, listing the kinds of data in the image.

TIFF can store files in black/white, grayscale, 24-bit, or 48-bit color modes, and a variety of color models, including RGB, L*a*b, and CMYK. If you've used Photoshop, you know that TIFF can store your levels and selections (alpha channels) just like Photoshop's native PSD format. It uses a variety of compression schemes, including no compression at all, Huffman encoding, LZW, and something called Pack Bits. Most applications can read TIFF files stored in any of these compression formats.

PICT

PICT is a file format that was developed in 1984 by Apple Computer as the native format for Macintosh graphics. PICT can include both bitmap images and vector (line-oriented) graphics. Although PICT is used primarily to exchange graphics between Mac applications, many PC programs, such as Photoshop, support it. Apple elected to replace PICT with PDF, beginning with Mac OS X.

PICT supports grayscale images as well as up to 24-bit color images. (It also can use 32-bit images, but the extra 8 bits are used for selections as an alpha channel.) PICT uses a Huffman-like run-length encoding (RLE) compression scheme.

PDF

PDF (Portable Document Format) is a format originally developed by Adobe to store PostScript files for printing on PostScript printers. Its advantage is that it preserves the original layout, fonts, and appearance of the file. PDF is often used with Adobe Reader or with browser plug-ins to display documents. I download instruction manuals, IRS tax forms, and other documents in PDF format.

More recently, PDF has gained some favor in the pre-press environment as a way of prepping documents for printing, and in the Macintosh world as a replacement for the PICT format. Because PDF files consist of PostScript text instructions, they can be highly compressed using any lossless compression method. Later versions of Photoshop and Photoshop Elements can save files in PDF format.

BMP

BMP was developed by Microsoft as a standard bitmap file format for computers running the Windows operating system. The intent was to produce device-independent bitmaps (DIB) that Windows can display on any type of device. BMP files can include color depths up to 24 bits.

RAW

As applied to digital cameras, RAW is not a standardized file format. RAW is a proprietary format unique to each camera vendor, and, as such, requires special software written for each particular camera. Each RAW format stores the original information captured by the camera, so you can process it externally to arrive at an optimized image. You'll learn more about RAW in the next section.

No comments:

Post a Comment