All digital image formats use some form of compression. As with audio compression, both lossless and lossy techniques are available. Some people are of the opinion that it is always better to use lossless compression but this isn’t nececessarily true for all kinds of images.

One of the principal techniques used for lossless compression is Run-Length Encoding (RLE) which is used for BMP (bitmap) files. RLE takes runs of consecutive pixels with identical values and stores them as a single data value and a count. It works best with simple graphics files with long runs of identical pixels.

DEFLATE is a lossless data compression technique used for Portable Network Graphics (PNG) images, as well as ZIP and gzip compression. PNG was created to get round patent restrictions with Graphics Interchange Format (GIF) and is the most widely-used lossless image compression format on the Internet. DEFLATE uses a combination of the LZ77 algorithm (one of several produced by Lempel and Ziv) and Huffman coding, which uses a variable-length code table derived from the estimated probability of occurrence of symbols.

Lempel-Ziv-Welch (LZW) compression, which we have already encountered in relation to ZIP files, is a lossless compression algorithm that performs limited analysis of data. It’s used in GIF and some TIFF (Tagged Image File Format) file formats.

Some lossy compression methods can be combined with lossless methods to create even smaller files. One common technique is to reduce the image’s colour space to the most common colours found in the image. This is often used in GIF and sometimes in PNG images. If this is used on the right types of images and combined with dithering (alternating pixels of different colours), it can produce images almost identical to the originals.

Transform encoding is used for JPEG (Joint Picture Expert Group) images. Transform coding averages out the colour in small areas of the image using a Discrete Cosine Transform (DCT) to produce an image that has far fewer colours than the original.

Chroma subsampling takes advantage of the fact that the human eye perceives changes in brightness more sharply than changes of colour. It drops or averages some chroma (colour) information while keeping luma (brightness) information. It is frequently used in video encoding and in JPEG images.

Next: Image File Types