Web DevCenter
oreilly.comSafari Books Online.Conferences.
MySQL Conference and Expo April 14-17, 2008, Santa Clara, CA

Sponsored Developer Resources

Web Columns
Adobe GoLive
Essential JavaScript

Web Topics
All Articles
Scripting Languages

Atom 1.0 Feed RSS 1.0 Feed RSS 2.0 Feed

Learning Lab

JPEG2000: the Killer Image File Format for Lossless Storage

by Ken Milburn, author of the upcoming Digital Photography: Expert Techniques

Digital cameras continue to feature larger image sensors, higher resolutions, and a variety of schemes for improving color fidelity and reducing the presence of image noise (think of image noise as digital grain). All of this adds up to two things that will ultimately affect the growth and progress of digital photography:

  1. Image quality so good that it threatens the continued use of film.

  2. Larger and larger image files.

The problem is that the continued use of currently popular image file formats, such as Tagged Image File Format (TIFF) and Photoshop Data (PSD), means that ultimate image quality can't be maintained without creating monster-size files. Even when one uses lossless compression with these formats, a 16-bit RAW image file from a pro or semi-pro 6MB (the resolution level at which digital truly begins to threaten 35mm film) camera file can easily swell to 25MB when stored on disk. (If you add a layer or two, that file size could easily double.) The typical 512MB memory card that these cameras use instead of film will hold approximately 38 RAW files. That works out to about 13MB each, because these RAW files are losslessly compressed. However, if you open the RAW file at 16 bits, at a resolution of 4256 by 2848, the resulting Photoshop file is 69MB! This is how professional photographers open their RAW files, simply because they want to start working with the best image quality possible.

Here's Where Lossless JPEG2000 Enters the Picture

If you were to save that 69MB file mentioned above as a .JPF (lossless JPEG2000) file in lossless mode, the same file is losslessly compressed down to 11.8MB. Before JPEG2000, the best we could hope for using lossless file compression would have been about 38MB, using TIFF LZW compression. At that size, you could only get about 18 exposures onto a 700MB CD-ROM used to archive your files. That's about half a roll of 36-exposure 35mm film. If you use the new JPEG2000 plug-in that ships with Photoshop CS, the same CD could hold about 60 files. That's equivalent to almost two rolls of film.

Though JPEG2000 is a new format that is not yet widely supported by image-editing and web-browsing applications, it can already be of major benefit to photographers who learn to incorporate it into their workflow routines. This article informs the reader just how to do that.

First, a Little Background

JPEG2000 is the first iteration of JPEG to offer:

  • Completely lossless image compression.

  • Transparency preservation in images.

  • Use of masks (alpha channels) to specify an area of the image that should be saved at a lower rate of data compression (loss of image information) than other areas of the image that are of less interest to the viewer.

  • EXIF data preservation in images.

  • User options as to the size, quality, and number of image-preview thumbnails on a web site.

JPEG2000, in addition to being a great way to efficiently store your highest-quality images, also has a great many benefits to offer web graphics, especially full-color images with transparent backgrounds. There isn't space to detail those benefits in this article; instead, we'll concentrate on the options in the JPEG2000 plug-in that most benefit the storage of high-quality files.

Related Reading

Digital Photography: Expert Techniques
Professional Tips for Using Photoshop & Related Tools to Enhance Your Digital Photographs
By Ken Milburn

How to Convert a File to JPEG2000 in Photoshop CS:

Let's step through the conversion routine. We'll use the JPEG2000 plug-in that ships with Photoshop CS and the JPEG2000 plug-in that comes with the Camera RAW plug-in, which can also be used with older versions of Photoshop:

  1. Copy the JPEG2000 plug-in from the Optional Plugins folder of your Photoshop CS CD to your plug-ins folder.

  2. If Photoshop CD is running, close and restart the program, so that the plug-in will be recognized.

  3. Open your RAW image using the Photoshop CS File Browser (or use the Camera RAW plug-in that works with Photoshop 7, if you purchased and installed it before Photoshop CS was available). You will be able to make your most significant exposure, contrast, and color balance adjustments to the image data from your camera with no compromise in image quality.

  4. Make whatever other adjustments to the file you'd like. Remember, however, that you want to archive as much of the data in the original image as possible, as you may have reason to want to access the original image in the future. Don't take your adjustments beyond that point until after you've archived the original.

    Of course, there's no reason you shouldn't also archive later states of your work, if you think there's any reason you may not want to return to that state. However, JPEG2000 isn't capable of saving layers (it will save alpha channels, paths, and transparency), so you may want to save intermediate stages of the work you do as Photoshop PSD files, after you've archived the original.

  5. Choose File > Save As. Choose JPEG2000 from the list of file types.

  6. A large dialog, JPEG2000, appears (see Figure 1). On the right side of the screen, under the OK button, are several option boxes that you want to check: Lossless, Include MetaData (so that you can keep paths), and Include Color Settings. (Since we are not saving these files for the Web, the other settings can be left set to default.) Click OK.

Click for larger view
Figure 1. (Click on the screen shot to open a full-size view.)

Note: The file is being saved with a wavelet algorithm (similar to the type of compression pioneered by Luratech), so it will take a bit longer than usual for the file to write to disk.

Be sure to make a copy of the plug-in and put it on every CD you use for archiving your images. You will then be able to open the files in any image editor that is compatible with Photoshop 7 (or higher) plug-ins.

Working with Converted JPEG2000 Files

Of course, you don't have to use a RAW file to convert to JPEG2000. You will still save drive space if you back up all of your standard-format lossless files, such as TIFF and PSD. The quality of the images will not be compromised, but you will lose all your layers (but not masks), so you won't be able to change information that was stored on a layer. The procedure is identical to steps 4 and 5 in the preceding section.

When Saving Space Is More Important than Absolute Fidelity

You also have the option of saving your JPEG2000 images to a lossy format that can be up to 200 times smaller than a comparable-quality smaller JPEG. This is a worthwhile option to consider if you have to transmit high-quality files over the Internet, as the time saved can easily outweigh the loss of data. If you use a high-quality setting, it takes an expert to tell the difference. In Figure 2, you see two small sections of the same part of the same image of driftwood on a beach. The image on the left was saved to a lossless PSD file and requires just over 9MB to store. The same section of the image, shown on the right, was stored in "lossy" JPEG2000 at a quality level of 50. The stored file uses only 1.1MB.

Click for larger view
Figure 2 (Click to open a full-size view.)


As space-saving as JPEG2000 is, it's not always the answer. You can't save layers in JPEG2000, so if you've created layers or adjustment layers that you may want to adjust later without having to repeat all of that tedious work, you should save to the original file format for your image editor. In the case of Photoshop (regardless of version), the appropriate file format would be PSD. Those using image-editing programs other than Photoshop (or versions older than Photoshop 7) may wonder whether they, too, can save to JPEG2000 format. Luratech makes a variety of plug-in and standalone software products that may do the job for you. The possibilities are too complex to detail here, but the following link is a good place to start: www.luratech.com/products/lurawave_jp2/.

Ken Milburn has been a photographer, both full- and part-time, for nearly five decades. In addition to countless articles, Ken has written 17 books on web design, Flash, Photoshop, and digital photography. His latest book, for O'Reilly, Digital Photography: Expert Techniques, was released in March 2004.

Related Reading: Digital Photography Pocket Guide, 2nd Edition.

Return to the Web Development DevCenter.