Data Compression‎ > ‎

Image Compression

Images make up a very big part of the (web page traffic) data on the Internet. This is because an image contains a lot of information compared to text. Even a small image sized 200 by 200 (pixels) saved in the bitmap format (using a 24 bits per pixel storage system) can take up 200x200x24 = 960,000 bits or 960,000/8 =  120,000Bytes = 117.1975Kilobytes (120000/1024 = 117.1875). Below is the image saved in the bitmapgifpng and jpeg formats. The last three are popular web page formats. As can be seen the most efficient format is jpeg at 8KB file size because it is designed to store information on millions of colours that may blend into each other e.g. a photograph or complexly coloured image. The least efficient is bitmap, and that is why this type of image is not commonly found on web pages (though browsers can display it). Both gif and png are designed to store images that have relatively distinct areas of plain colours.

 Bitmap (118KB)  Jpeg (8KB)  Gif (27KB)  Png (25KB)

Jpeg, Gif and Png use their own compression algorithms. A comparison table is below. Also, each format is either lossy or lossless in nature. Lossy means some of the original raw image data is discarded when it is saved in the format. Lossless means no data is discarded. In addition, when saving an image in the Jpeg format a quality setting can be specified, with 100 being the maximum value. Lower settings result in smaller file sizes, but at the expense of image quality. Look at the two images in the second table below.

Image Format Encoding/compression scheme Lossy or lossless compression
Jpeg JFIF  Lossy
Gif LZW  Lossless
Png Deflate  Lossless

Jpeg image quality

Quality setting of 100, file size 136KB
Quality setting of 30, file size of 69KB. Note artefacts (discoloured pixels) around the blades and banding of the colours in the sky.

Run length encoding

A simple type of image compression is called run length encoding. It is used by fax machines to compress black and white images into a more manageable file size for transmission. The following link points to a pdf on the CS Unplugged website that shows how it is done using a method called run length encoding. Activities are also included.: image representation

Additional useful information and links can be found at the bottom of this page in the site

Programs to convert and edit images

Below is a list of programs to convert one type of image format to another and to edit such properties as bit depth and number of colours.


  • Irfanview - an excellent, free, fast general purpose converter, properties inspector and editor.
  • Photoshop - an industrial strength image creation and editing program; expensive and over the top for properties inspection or conversion.
  • The GIMP - free, no thrills, but very accomplished alternative to Photoshop; also over the top for basic tasks.


  • iPhoto - comes with a Mac.
  • Photoshop - see above.
  • The GIMP - see above.
  • Seashore - free, similar to The GIMP, but more basic.
  • Irfanview - can be used via a virtual machine; click on this link to see how.


  • The GIMP - see above.
  • Irfanview - can be used via a virtual machine; click on this link to see how.