KS3 · Computer Science
Compressing data
Your phone is probably full of photos, and they've already had data thrown away: data you can't see and will never get back. That's exactly why they fit.
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 it and keep comparing "restored" with "original".
Predict before you step: 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 is the row: 12 pixels, so 12 values to store. Look at those long runs of the same colour. Repeats like that are what compression hunts for.
Use Next to step. The line to watch is "same as original?".
Why compress?
Reason it through
Why do we bother compressing files at all?
First link · your turn
Everything on a computer, including text, pictures and sound, is stored in binary. 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, and small changes you almost certainly won't notice.
Where the line is: Only fine when a tiny loss of detail won't matter for what the file is used for.
Lossless (0)
Every bit must come back exactly as it was.
Where the line is: Needed 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 belongs, 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
- Compression reduces the number of bits used to store data, while keeping the important information.
- Smaller files need less storage space and are quicker to upload, download, stream and share.
- Lossless compression loses nothing: decompressing gives back an identical copy of the original.
- Lossy compression permanently removes some data: decompressing gives back an approximation, never an exact copy.
- Compression changes a file's data, not its fundamental properties: a picture keeps its resolution and a song keeps its length.
The big picture
Images and sound are stored as very long sequences of bits, which take up space and take time to transfer. Compression reduces the number of bits while keeping the important information. Lossless compression stores repeated patterns more efficiently and gives back an identical copy. Lossy compression permanently removes some data, typically makes smaller files, and gives back only an approximation. Choose lossless when every bit matters, and lossy when small changes won't be noticed.
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's left.
Memory hook
LossLESS: you get back no less than you started with. LossY: some data is lost, and the computer can only guess it back.
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 where would that really matter?
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
- Abstraction in computational thinking
- Adding binary numbers
- Binary to denary conversion
- Boolean logic: AND, OR, NOT
- Bubble sort
- Building truth tables
- Client-server vs peer-to-peer
- Collecting and recording data
- Comparing sorting algorithms
- Creating a 3D animation
- Decomposition: splitting problems up
- Designing a mobile app
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 1 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.