Lossless vs lossy compression of images
Image formats
Digital photographs are comprised of a large array of pixels. Those dot-like pixels have varying amounts of the primary colors mixed together to form the final color of those dots. All image formats are simply ways of storing the image information in a computer file until the original image is reconstituted for displaying or for printing. The differences in the formats have primarily to do with the information that is stored and the efficiency with which it is stored.

Image resolution includes a measure of the pixel density of an image. In reality this would be the number pixels in a given area of the image. However, practically speaking it is given as the number of pixels per inch of linear distance. It is assumed that this linear density is the same horizontally and vertically. In printing, the density is often referred to as "dpi" or "dots per inch," which is equivalent to pixels per inch.

In addition to the spatial resolution given by pixel density, there may be differences in the color depth. The individual pixels of a digital image are generally stored in the computer in a mix of amounts of red, green and blue in a color mode called RGB. Most commonly, the intensity of the color these three channels is represented by an 8-bit number which in turn means that there are 256 different levels of each color. In some cases more bits are used to represent each color, giving greater depth of color representation. For printing processes, 8 bits per color channel or 24-bit color, is probably greater than the printing method can represent. However, for film processes using transmitted light, or for the flexibility in image processing for detail, more color depth can be quite useful. Practically speaking most images and most image processing is carried out at a 24-bit color depth.

Image compression
Inventors and software  engineers have devised clever ways to store a given amount of digital information in a smaller space. Virtually all image formats have one or another of these methods of compression applied to them for making the overall file size smaller. When the compression method allows the original image to be reconstituted intact, without loss of any resolution, it is called "lossless compression.

The TIFF file format can fully specify the content of an original bit mapped image. ZIP, LZW and CCITT are the names of a few of the compression algorithms that have been applied to shrink TIFF images and still allow them to be fully reconstituted. In principle there is nothing wrong with an image compressed with one of these techniques. In practice, the RIP used by many commercial print on demand printers can have issues processing LZW or CCITT compressed TIFFs.

PNG is another lossless image format with some more advanced image compression techniques. It generally results in somewhat smaller file size than compressed TIFF files. In addition to RGB color channels, PNG has an "alpha" channel for specifying a transparency level for each pixel. RIP software sometimes has issues with transparencies in other images. I do not know if these issues are a problem with PNGs in PDFs.

Lossy compression
Lossy compression is achieved by combining standard compression techniques plus simplifications to the image that reduce the amount of data required to store it. An older style of lossy compression is GIF. With GIF, the colors in an image are reduced to a 256 color palette. This limits the ability to faithfully render photographs but it may work fine for some illustrations that may have relatively few colors in their palettes. It can be very useful for line drawings.

A very popular image format, jpeg, is also lossy. The simplifications that go into jpeg compression make clever use of knowledge about the limitations of human visual discrimination. In saving an image in jpg format one can usually choose a value for the "quality" of the image or the amount of compression. The goal in lossy compression is to reduce the file size further than is possible with lossless compression but to keep the appearance of the image as intact as possible while making the simplifications. There is an almost continuous trade off that can be made between the apparent resolution of the image and the reduction in file size.

The numbers that a given image application assigns to the quality level is an arbitrary number that may or may not correlate with the same quality number of another application. Some applications that use software routines from the Independent JPEG Group (IJG) have quality levels that are directly comparable. Importantly, a quality of 100 or maximum, is not lossless. On the other hand, the color output of printing devices is sufficiently limited that even lower jpeg quality settings can be indistinguishable from the printed output of a TIFF image.

Video displays generate colored light while printed images are limited to reflecting light that is not absorbed by the colors of the image. Because of that, the range of colors and intensities that can be distinguished in looking at a video display of an image is greater than the range of colors and intensities that can be distinguished in a printed image. Thus, in general, if you cannot see the losses in a jpg when looking at it on your screen, you are highly unlikely to be able to distinguish those losses in the printed output.

The test photograph below was converted from a "raw" digital camera image. (It is shown here reduced to 1/3 original size.)

Original png

This raw image was converted to TIFF and then saved in several other file formats to test the size of the image in those formats.

File sizes for identical images saved in non-lossy formats:
TIFF 11.2 Mb  
TIFF with LZW compression 7.3 Mb
PNG 6.2 Mb  

File sizes for this image saved with various JPG quality settings in The GIMP:
JPG quality-100 (maximum quality) 3.0 Mb
JPG quality-88  0.93 Mb
JPG quality-80  0.69 Mb

Note that the "quality" values in various applications are arbitrary. They will only be equivalent in applications that use the same underlying software routines for compression. Notice that JPG with The GIMP's quality setting of 80 results in almost a 20-fold reduction in file size. How much does that compression decrease the actual noticeable quality of the resulting image?

Note also that PNG compression is more effective than LZW compression of TIFF files. This is important since LZW compression is often not compatible with commercial printers.

Below are the same section of the test image after being saved as PNG, JPG quality100, JPG quality88 and JPG quality80 (but not in that order). The images are at 100% gain. Can you perceive the difference in these blow ups with this kind of test? I doubt it.

Even when the images are stacked one on top of the other and then switched rapidly, the differences are extremely hard to notice. Not only are the differences very difficult to discern--it is even more challenging to decide, regardless of small differences, which image is superior. If the PNG is not distinguishable from the JPG-80, you should ask yourself what you are getting for all that extra storage space required by the file.

ATest image

test image

test image

test image

So, lets put the compared sections side by side:
detail image
detail image
detail image
detail image
You might convince yourself that the difference is noticeable. I am skeptical. I have put one image on top of another and switched back and forth rapidly trying to find differences. What differences I see are minimal. Importantly, the printing process will give you less detail than any of these screen images.

Some images are not ideal for JPG compression
JPG is terrific for photographs where there is considerable detail. The compression techniques are not as well suited for images where there are sharp lines dividing areas of single color. Such images include diagrams, art with text and some architectural images. The following image is an example:
circle test image
Original PNG at 100 %
jpg 100
JPG quality 100
jpg 88
JPG quality 88
JPG 80
JPG quality 80

File sizes:
PNG  5,076 bytes
JPG-100  13,890 bytes
JPG-88  6,708 bytes
JPG-80  5,460 bytes

The PNG file is the smallest and it is also lossless. This is because the PNG format can take advantage of the low number of colors and the large areas of single color to greatly reduce file size.

Magnified images detailing the introduction of "jpeg artifact" with higher levels of jpeg compression:
circle test

circle test image
JPG 100

circle test image
JPG 88

circle test image
JPG 80

The bottom line:
JPG compression of photographs is extremely effective at reducing file size of some photos with minimal loss of printed image quality. By contrast, PNG compression of images with large blocks of single color maybe both more efficient and greater in printed quality.

©2006-2009 by Don Campbell
last edited 11/01/2009