There are many methods of compressing graphics files. This page attempts to demonstrate how lossless and lossy compression compare. The test data for this demonstration is a 24-bit color image. The bar graph in the last column of these tables is intended to provide a visual comparison of the relative file sizes.
First, we compare several lossless techniques:
Compression Method | Resulting Size | Resulting Percent | Visual Comparison |
---|---|---|---|
Uncompressed image | 4,261,256 bytes | n/a (100%) | |
24 bit PNG | 2,081,345 bytes | 52% | |
8 bit PNG | 620,254 bytes | 86% | |
JPEG 100% | 967,111 bytes | 78% |
Note: Comparing 8 bit PNG to the 24-bit raw data is misleading. Although PNG is a lossless compression method, using only 8 bits of color represents a loss of 16 bits per pixel. Note also: strictly speaking, the JPEG method, even at 100%, is a lossy compression method.
Lossy compression can have a much more significant payoff, but always at the expense of some image quality:
Note: the uncompressed 24-bit image uses 130,851 colors.
Selecting the best compression method for any particular image depends on many factors: the number and distribution of colors, the image quality required by your application, and the nature of the tools that must manipulate or display the image. Running comparisons similar to the ones shown above on your real images will provide a better indication of the payoff for your particular application than we can provide in the general case.
For further information on compression of all kinds, see the comp.compression newsgroup FAQ.
Copyright © 1996 O'Reilly & Associates, Inc. All Rights Reserved.