KS3 · Computer Science
Compressing data
If your phone saves photos as JPEGs, each one was quietly squashed: some data is gone for good, and you usually can't tell.
Computing · Data compression
One row of pixels, squashed two ways
A simplified model of one row from a tiny image: 12 pixels, where W = white, L = very light grey and B = black. Step through and keep comparing "restored" with "original".
Before you press Next: will both methods give you back exactly the row you started with?
1 original ← W W W W W L W B B B B B2 LOSSLESS: store each run as count + colour3 stored ← 5W 1L 1W 5B4 decompress: write each colour 'count' times5 restored ← W W W W W L W B B B B B6 LOSSY: L is almost white, so store it as W7 stored ← 7W 5B8 decompress: write each colour 'count' times9 restored ← W W W W W W W B B B B B10 compare each restored row with the original
Variables
Output
Step 1: Here's the row: 12 pixels, so 12 symbols to store. Notice those long runs of the same colour? Repeats like that are exactly what compression goes hunting for.
Press Next to step. The line to keep your eye on is "same as original?".
Why compress?
Reason it through
Why bother compressing files at all?
First link · your turn
Text, pictures and sound all end up stored as binary. So is a photo or a song a short string of bits, or a long one?
Your call
Lossy or lossless?
Which kind of compression suits each file best?
Still to sort
Lossy (0)
Smaller files; the changes are usually too small to notice.
Where the line is: Fits when losing a little data won't matter for what the file is used for.
Lossless (0)
Everything comes back exactly as it was.
Where the line is: Fits when the data has to be fully restored without any loss, even if the file ends up bigger.
Place each file where you think it fits best, then read why.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
How files get smaller, and what you really get back when you open them again.
What you need to know
- Pictures and sound are stored as bits, and their sequences of bits can get extremely long.
- More bits means more storage space, and more time to transfer the file.
Have a goYour mate insists a 3-minute video and a 3-word text will upload equally fast, "because it's the same Wi-Fi". Who wins the race?
The text, by miles.
Same Wi-Fi, yes, but the video is a far longer sequence of bits, and more bits take more time to transfer. The connection isn't the only thing that matters.
- Compression reduces the number of bits used for data, while keeping the important information.
- Smaller files win twice: more fit on a device, and they upload, download, stream and share faster.
- A compression algorithm makes the file smaller; a decompression algorithm undoes those steps so you can open, view or play it.
- Lossless compression stores repeated patterns more efficiently, and decompressing gives back an identical copy.
- Lossy compression permanently removes some data, so decompressing gives only an approximation, never an exact copy.
Have a goA lossy method turned a light grey pixel into white before storing it. Could decompressing the file twice get the grey back?
No. The grey is gone for good.
Lossy removal is permanent: decompression rebuilds only from the data that was kept, so running it again gives the same approximation.
- Compression changes the data, not the file's fundamental properties: a photo keeps its resolution, a song its length.
- With a compressed format, compression and decompression happen automatically. No button to press.
- Lossy usually makes smaller files; lossless wins when every character, number or detail must come back.
Have a goPick a method for each: (a) a spreadsheet of exam marks, (b) a holiday photo for a group chat.
(a) lossless, (b) lossy.
Every mark must come back exactly, so lossless; for the photo, a little lost data usually goes unnoticed and the smaller file sends faster.
The big picture
Images and sound need extremely long sequences of bits, which cost storage space and transfer time. Compression reduces the number of bits while keeping the important information, so more files fit and they transfer faster. Lossless compression stores repeated patterns more efficiently and decompresses to an identical copy. Lossy compression permanently removes some data, so decompression gives only an approximation; it usually makes smaller files and suits images and sound. Choose lossless when everything must come back exactly, and weigh the drawbacks too.
Key points
Worked example
Problem
Maya records her band's new song. She'll keep editing the recording for a few weeks, then share the finished track online with fans. Should she use lossy or lossless compression at each stage? Explain your choices.
⚠ Watch out
Thinking that decompressing a lossy file brings back exactly the original. It can't: the removed data is gone, so decompression rebuilds only an approximation from what was kept.
Memory hook
LossLESS: you get back no less than you started with. LossY: "Y did some of my data disappear?" Because it was lost for good, so you only get back an approximation.
Check yourself
Cover the page. A file is compressed, then decompressed, and comes back identical, bit for bit. Lossy or lossless? How do you know, and name one kind of file where that really matters.
Flashcards
(14)What is compression?
Why do image and sound files get so big?
Two benefits of compressing a file
What does a compression algorithm do?
What does a decompression algorithm do?
Lossless compression
Lossy compression
Does compressing a bitmap image lower its resolution?
Does compressing a song make it shorter?
Do you usually have to compress files yourself?
Why is lossy used for JPEG photos and MP3 music?
Which usually makes the smaller file: lossy or lossless?
When is lossless the better choice?
Three drawbacks of compression
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore KS3 Computer Science topics
How this lesson was checked. This KS3 Computer Sciencelesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 27 October 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.