Menu

Compression is the process of reducing the size of a file using an algorithm. The data is stored using fewer bits, so the compressed file usually takes up less space than the original.

Compression is not the same as encryption. Encryption scrambles data so that other people cannot read it, while compression only makes a file smaller. Anyone who has a compressed file can unpack it and read what is inside, so compressing a file does not keep it safe.

Getting the data back

Decompression is the reverse process: it turns compressed data back into a usable state. A compressed file has to be decompressed before the data inside it can be used normally. For example, a phone might store a photo in a compressed form to save space on its storage card. When you tap the photo, the app decompresses the stored version into memory so the screen can show the whole picture. The file on the card stays small, and the version you are looking at is the unpacked one.

Two types

There are two main types of compression. Lossy compression permanently removes some data, so the original can never be rebuilt exactly. Lossless compression keeps every piece of data, so decompression restores the original exactly.

Compression is used most often on sound, image and video files, because these are usually among the largest files people handle and they can be squeezed a long way. A single uncompressed photo or song can be several megabytes, and packing it often shrinks it to a small fraction of that size.

File sizes are measured in bytes, or in kilobytes and megabytes for larger files, so you can work out the space saved as a percentage of the original size.

Practise this