Digital files — especially images, audio, and video — can be very large. Compression reduces file size so that:
There are two main types of compression: lossy and lossless.
Lossy compression permanently removes data that is considered less important or less perceptible to humans. The original file cannot be perfectly reconstructed from the compressed version.
| Property | Detail |
|---|---|
| Data removed | Yes — permanently discarded |
| Reversible? | No — original cannot be recovered |
| File size reduction | Large — can reduce by 90%+ |
| Quality | Reduced — some detail lost |
| File examples | JPEG (images), MP3 (audio), MP4/MPEG (video) |
How it works (JPEG example): removes colour information from areas where the eye is less sensitive to detail — e.g. gradients in skies are simplified. Small details and colour variations humans can barely see are removed, reducing file size greatly.
How it works (MP3 example): removes audio frequencies that are masked by louder sounds or are too high/low for most people to hear clearly.
Lossless compression reduces file size without losing any data. The original file can be perfectly reconstructed from the compressed version. It works by finding patterns and redundancy in data and encoding them more efficiently.
| Property | Detail |
|---|---|
| Data removed | No — all data preserved |
| Reversible? | Yes — original perfectly restored on decompression |
| File size reduction | Moderate — less reduction than lossy |
| Quality | Perfect — no quality loss |
| File examples | PNG (images), FLAC (audio), ZIP/RAR (archives) |
| Factor | Lossy | Lossless |
|---|---|---|
| Quality after compression | Reduced (data lost) | Perfect (no data lost) |
| File size reduction | Larger reduction | Smaller reduction |
| Can reconstruct original? | No | Yes |
| Best for | Photos, music, video streaming | Text, programs, medical images |
| Examples | JPEG, MP3, MP4 | PNG, FLAC, ZIP |
Run-length encoding is a simple lossless compression algorithm. It replaces consecutive runs of the same value with a (count, value) pair. It works best when there are long sequences of repeated values — common in images with large areas of the same colour.
Limitation: RLE performs poorly on data with very few repeated values (e.g. a photograph with many different colours). In the worst case, it can make the file larger.
Where RLE works well: simple graphics, icons, black-and-white images, fax transmissions.
8 questions · 20 marks
| Term | Definition |
|---|
10 questions · 10 marks · 10 minutes