kasim-lone.dev — data-representation / compression
← All topics

GCSE · Data Representation

Topic 7
Compression

Scroll to begin ↓

By the end you'll be able to…

  • Explain why files are compressed.
  • Describe how lossy compression works and give examples.
  • Describe how lossless compression works and give examples.
  • Compare lossy and lossless, and choose the right one for a scenario.

Why do we compress files?

Compression means reducing the size of a file so it takes up less space on secondary storage.

Two big reasons:

  • Storage. Fit more files on the same device — phones, tablets, laptops, servers.
  • Speed. Send data faster across a network — quicker uploads, downloads and streaming.

There are two methods of compression:

  • Lossy — throws data away.
  • Lossless — reorganises data so the original can be recovered.

Lossy compression

  • Data is lost to reduce the file size.
  • Irreversible — the original file cannot be recovered from the compressed version.
  • Can shrink files dramatically, but at the cost of quality.
  • Only suitable when a drop in quality is acceptable — images, video and sound.

Example: in a photograph, lossy compression groups similar colours together, reducing the total number of colours without a big visible change.

✏️ Real example

Original JPG: 824 KB
50% lossy compression: 76 KB (looks nearly identical)
80% lossy compression: 38 KB (quality noticeably drops)

Slide to compress

Drag the slider to increase the level of lossy compression. Watch the file size drop — and the quality with it.

// photograph
0% lossy · 824 KB

Notice how small changes at low levels don't hurt the picture much — but pushing compression too high loses detail you can't get back.

Lossless compression

  • Data is encoded, not lost.
  • Reversible — the original file can be recovered exactly.
  • Reduces file size, but not as much as lossy.
  • Used where any loss of quality is unacceptable — documents, code, spreadsheets, some images.

A common technique: look for patterns and repetition. Repeating characters can be replaced with a single character + a count.

✏️ Example — run-length encoding

"EEEEE" → E5. Same information, fewer characters. When the file is opened, the algorithm reverses this to get "EEEEE" back.

When you open a compressed document, the software decompresses it automatically. Formats like .docx, .pdf, .zip and .png all use lossless compression.

Lossy vs Lossless

LossyLossless
What happensData is thrown awayData is re-encoded
Reversible?No — original is lostYes — original recovered exactly
Size reductionLargeSmaller
QualityReducedUnchanged
Best forImages, video, soundDocuments, code, some images
Example formatsJPG, MP3, MP4PNG, ZIP, DOCX, PDF

Flip cards

Exam-style practice

Q1. Give two reasons why files are compressed.

Q2. Sarah records an audio file and emails it to a friend for proofing. Explain two reasons why using lossy compression is beneficial. [4]

Q3. Explain why lossless compression is preferred for word-processed documents.

Q4. Describe how lossless compression can reduce the size of a text file.

// end of topic 7 — compression