In simple terms
A friendly intro before the formal notes — no formulas yet.
Shrinking Digital Files
Compression makes files smaller for faster transmission and more efficient storage. It works by finding and reducing redundancy in data, either perfectly (lossless) or by discarding imperceptible information (lossy).
Imagine packing a suitcase. Lossless compression is like neatly folding and vacuum-packing your clothes. Everything fits into a smaller space, and when you unpack, every single item is there, exactly as it was. Lossy compression is like deciding you don't really need five pairs of shoes and leaving three pairs behind to make the suitcase much lighter. You've saved a lot of space, but you can't get those shoes back once you've arrived.
- 1
Lossless compression — exact reconstruction (ZIP, PNG, FLAC).
- 2
Lossy compression discards imperceptible detail (JPEG, MP3).
- 3
Run-length encoding (RLE) for repeated data.
- 4
Exam: calculate compressed vs uncompressed file sizes.
Explore the concept
Use the live diagram and synced steps — play it or tap a step card to walk through.
Key formulas
Tap any symbol to reveal exactly what it means and its units.
Full topic notes
Formal explanation with the rigour you need for the exam.
The Two Flavours of Compression: Lossless and Lossy
All compression techniques aim to reduce file size, but they achieve this in two fundamentally different ways. The choice between them depends entirely on the nature of the data and its intended use. The core distinction is whether it is acceptable to lose any information in the process.
Lossless Compression: Perfect Reconstruction
Lossless compression reduces file size without discarding a single bit of the original information. It works by identifying and eliminating statistical redundancy. When the file is decompressed, it is restored to its exact original state. This is crucial for files where any data loss would be catastrophic, such as text documents, computer programs, or scientific data. Common examples include ZIP archives, PNG images, and FLAC audio files.
Advantage: No loss of quality or data; the original can be perfectly restored.
Disadvantage: Achieves less reduction in file size (lower compression ratio) compared to lossy methods.
Use Cases: Archiving files (ZIP, RAR), source code, text files, and images where fidelity is key (PNG).
A Lossless Technique: Run-Length Encoding (RLE)
Run-Length Encoding is one of the simplest forms of lossless compression. It's particularly effective on data with long sequences (or 'runs') of repeated values. Instead of storing every individual value in a run, RLE stores the value once, along with a count of how many times it repeats. For example, the text string AAAAABBBCCCC could be encoded as 5A3B4C. This is very effective for simple bitmap images, like icons or logos, which often have large areas of a single colour.
Lossy Compression: Trading Quality for Size
Lossy compression achieves much higher compression ratios by permanently deleting data. The key is that it discards information that human senses are less likely to notice. For an image (JPEG), this might mean removing subtle variations in colour that the eye won't perceive. For audio (MP3), it involves removing frequencies at the very high or low end of our hearing range, or sounds that are masked by louder sounds. Because data is permanently lost, the original file can never be perfectly recovered.
Advantage: Achieves very high compression ratios, resulting in very small files.
Disadvantage: Quality is degraded and original data is permanently lost. Repeatedly saving a lossy file can cause cumulative quality loss.
Use Cases: Multimedia where perfect fidelity is not essential, such as streaming video (MPEG-4), digital photos (JPEG), and music (MP3, AAC).
When an exam question asks you to recommend a compression type, justify your answer based on the data. If the data is a program, financial records, or a medical scan, you must choose lossless and explain that data integrity is paramount. If it's for streaming a movie or sharing a holiday photo on social media, lossy is more appropriate because file size and transmission speed are more important than perfect fidelity.
Calculating File Sizes and Compression
A common exam task is to calculate file sizes. You must know the standard formulae for uncompressed bitmap images and PCM sound files. Remember to be careful with your units!
Uncompressed Image Size (bits) = Image Width (px) × Image Height (px) × Colour Depth (bits)
Uncompressed Sound File Size (bits) = Sample Rate (Hz) × Sample Resolution (bits) × Number of Channels × Duration (s)
Worked examples
See the formulas applied — reveal one step at a time, like the exam.
A simple 8x4 pixel monochrome (1-bit colour depth) image is represented by the following binary data, where 1 is black and 0 is white. The data is read row by row.
00000000 01111110 01111110 00000000
Apply Run-Length Encoding to this data. Assume the format is (count, value).
- 1
Analyse the data stream: First, we read the pixels as a single stream: 00000000011111100111111000000000
An uncompressed digital photograph has dimensions of 4000 x 3000 pixels and uses a 24-bit colour depth.
(a) Calculate the file size of the uncompressed image in mebibytes (MiB). (b) The image is compressed into a JPEG file of size 4 MB. Calculate the compression ratio.
- 1
Calculate total pixels:
How it all connects
The big idea sits in the middle — tap a linked idea to explore the link.
Tap a linked idea to see how it connects back to the main topic — that connection is what examiners reward.
Glossary
Try to recall each definition before you reveal it.
Quick check
Answer in your head first — then tap to check. No pressure.
Revision flashcards
Flip the card. Test yourself before the exam.
What is compression?
The process of reducing the size of a data file by using an algorithm to encode the information using fewer bits than the original representation.
Key takeaways
Review these before you close the topic — retrieval beats re-reading.
- ✓
Advantage: No loss of quality or data; the original can be perfectly restored.
- ✓
Disadvantage: Achieves less reduction in file size (lower compression ratio) compared to lossy methods.
- ✓
Use Cases: Archiving files (ZIP, RAR), source code, text files, and images where fidelity is key (PNG).
Practice — then mark it
The whole point: a real Cambridge question, marked mark-by-mark.
Test Your Knowledge on Compression
Test Your Knowledge on Compression
Extra simulations & links
PhET, GeoGebra and other curated tools — open in a new tab.
Frequently asked
Checkpoint
One marked question is worth ten re-reads — close the loop before you move on.
Reading it isn’t knowing it — prove it.
Before you move on: do Test Your Knowledge on Compression on paper, snap a photo, and get examiner-style feedback on exactly where you win and lose marks.