Menu

Distribution considerations

Compression

Contents

  1. Compression
  2. Lossy compression
  3. Lossless compression
  4. Decompression
  5. Comparing lossy and lossless compression

Compression is the process of reducing the size of a file by reducing the amount of data it contains. A compressed song, poster or game level still plays, opens or works, but it takes up less room.

Why compress a file?

Every file you store or send costs space and time, and compression cuts both:

  • Storage — a phone, memory card or school network drive holds far more files when each one is smaller, so you run out of room less often.
  • Transfer — a smaller file uploads, downloads and streams more quickly, because there is less data to push across the connection.
  • Web pages and online media — a photo-heavy page opens sooner on a weak mobile signal, a video streams with less buffering, and a podcast episode downloads faster before a journey.

What it can cost

The two main types are lossy compression and lossless compression. Lossy compression discards some of the original data, so the file can lose quality — though often you would not notice unless it is squeezed very hard. Lossless compression throws nothing away, so the original quality is kept. Which one suits a file depends on whether its exact contents must survive.

A worked example: a 300 MB project file takes 60 seconds to upload over a connection that carries 5 MB every second. Compressed to 60 MB, the same upload takes 12 seconds. The time saved by sending less data is often worth more than the space saved on the drive.

Lossy compression reduces a file's size by removing or discarding some of the original data. The file still opens, plays or displays, but it no longer holds everything the original did, so some quality is lost — and that removed data can never be put back.

How much is thrown away?

Lossy compression usually gives a significant reduction in file size. You often choose the compression level yourself, and the more heavily a file is compressed, the more information is lost.

  • Light compression keeps most of the detail, so the result usually looks or sounds the same as the original.
  • Heavy compression discards much more, and the drop in quality becomes easy to spot.

Imagine a school orchestra recording a rehearsal on a phone to send to a group chat. At a light setting the strings and voices sound as they did; squeeze the same recording much harder and the cymbals smear and quiet passages go fuzzy. That copy is fine for a quick message, but not for selling the concert CD.

Digital artefacts

Heavy compression can cause digital artefacts: visible or audible damage that was not in the original. A picture may show pixelation, where smooth areas break into blocks and edges look jagged; audio can turn watery or metallic. At moderate settings the loss is normally hard to notice, which is why the method is so widely used.

When to use it

Lossy compression suits any situation where a smaller file size matters more than keeping every piece of original data or perfect quality, such as shrinking a photo before you send it so it uploads quickly over a weak connection. It is the wrong choice when the file must stay identical, like a spreadsheet of race times where every hundredth of a second counts. It removes detail inside a file; it never removes whole files or whole sections.

Lossless compression makes a file smaller without throwing away any of the original data. Every detail that was in the file is still there afterwards, so the quality stays exactly as it was.

When every detail has to stay

Lossless compression is used when the contents of a file must stay exactly the same and any loss of data would be unacceptable. Imagine a vet takes an X-ray of a dog's leg and stores it in the practice's records. The image must stay exactly as it was so a tiny hairline fracture is still visible when another vet checks it weeks later. Compressing the X-ray losslessly means it takes up less storage space and is quicker to send, yet none of the original image data has been lost.

Smaller savings, nothing lost

Lossless compression usually gives a smaller reduction in file size than lossy compression. The file does get smaller, just not by as much, because no data has been removed to free up space.

For example, a 40 MB X-ray might shrink to about 16 MB with lossless compression. Lossy compression could take the same X-ray down to 3 MB, but only by removing some of the detail, and a fine hairline fracture could end up blurred. So lossless is the right choice whenever keeping every piece of the original data matters more than making the file as small as possible.

Decompression is the process of restoring a compressed file so it can be opened, read, played or used. When you download a compressed file, the software you use usually decompresses it first, because most apps can only work with a file once its data is back in its usual format. The decompressed file also takes up more storage space again.

The result depends on how the file was compressed. With lossless decompression, the decompression algorithm rebuilds every piece of the original data, so the decompressed file is exactly the same as the file before compression. For example, a scanned copy of a signed trip consent form might be compressed losslessly to save space when emailed; when the school office decompresses it, every letter and signature is identical to the original scan.

With lossy decompression, the file is rebuilt so it can be used, but the data removed during compression cannot be put back. The decompressed file is not exactly the original. A recording of a school choir rehearsal compressed lossily for a highlights video will still play after decompression, but the quietest details that were discarded are gone for good.

Compression and decompression are different

Compression reduces file size. Decompression restores a compressed file for use. They are opposite processes, not the same one.

Type of compressionWhat decompression doesDecompressed file compared with the original
LosslessRebuilds all the original dataExactly the same
LossyRebuilds a usable file, but removed data stays removedClose, but not identical

Both lossy and lossless compression make a file smaller. The important difference is what happens to the original data and to the quality.

Lossy compression

Lossy compression makes a file smaller by discarding some of the data or detail. This can lose quality, especially if the file is compressed heavily, but it usually gives the largest reduction in file size: a 24 MB file might become 6 MB. Choose lossy compression when a much smaller file matters more than keeping every piece of original data or perfect quality. It does not delete whole files; it reduces the amount of detail stored inside the file.

Lossless compression

Lossless compression reduces file size without removing any data. Nothing is discarded, so the contents stay exactly the same and the original quality is kept. It usually gives a smaller reduction in file size: the same 24 MB file might become 18 MB. Choose lossless compression when the contents must stay exactly the same and any loss of data is unacceptable.

Comparing the two

FeatureLossy compressionLossless compression
Original dataSome data or detail is removedNo data is removed
QualityMay be reduced, especially with heavy compressionOriginal quality is kept
Typical size reductionLarger reductionSmaller reduction
Best choice whenA much smaller file is more important than perfect qualityThe contents must stay exactly the same