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 B
2 LOSSLESS: store each run as count + colour
3 stored ← 5W 1L 1W 5B
4 decompress: write each colour 'count' times
5 restored ← W W W W W L W B B B B B
6 LOSSY: L is almost white, so store it as W
7 stored ← 7W 5B
8 decompress: write each colour 'count' times
9 restored ← W W W W W W W B B B B B
10 compare each restored row with the original

Variables

original=W W W W W L W B B B B Bvalues stored=12

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.

1 / 6

Use Next to step. The line to watch is "same as original?".

Step 1 of 6: 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..

Watch out: Decompressing a lossy file does not bring the removed detail back. It rebuilds a best guess from the data that is left.

Why compress?

?

Reason it through

Why do we bother compressing files at all?

Link 1 of 4

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?

2
Locked — reveal the link above first
3
Locked — reveal the link above first
4
Locked — reveal the link above first

What do you think?

What has compression actually done?

Your phone has just saved a photo, and you've downloaded a song. Both files are compressed.

Which idea is closest to what you think right now?
How sure are you?

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.

6 of 6 still to sort.

Place each file where you think it belongs, then read why.

Weigh it up

Should you squash your music?

The claim

Storing my music collection as highly compressed lossy files is a good idea.

Place each piece of evidence to load the balance. Mark the strong ones — they count double.

  1. The files take up much less storage space, so more songs fit on my phone.

    Evidence 1: does it support or challenge the claim?
  2. Smaller files download, stream and share faster.

    Evidence 2: does it support or challenge the claim?
  3. Lossy changes to sound are usually too small for the human ear to notice.

    Evidence 3: does it support or challenge the claim?
  4. A highly compressed audio file may sound distorted or less clear.

    Evidence 4: does it support or challenge the claim?
  5. If I edit a track and re-save it, its quality can drop even further.

    Evidence 5: does it support or challenge the claim?
  6. Some of my equipment might not support the compressed format.

    Evidence 6: does it support or challenge the claim?

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

1Images and sound need extremely long sequences of bits, and more bits mean more storage and longer transfers.
2A compression algorithm makes a file smaller; a decompression algorithm undoes those steps so the file can be opened, viewed or played.
3Lossless works by finding repeated patterns and storing them more efficiently.
4Lossy is common for images and sound, such as JPEG and MP3, because the changes are usually undetectable to our eyes and ears.
5Lossy typically makes smaller files, but lossless is the better choice when data must come back without any loss, such as documents or medical images.
6When a file format is compressed, compression and decompression happen automatically; you don't normally choose.
7Drawbacks: heavy lossy compression can make audio sound distorted, re-saving an edited lossy file can lower quality further, and some equipment may not support a compressed format.

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?
Any process that reduces the size of a representation, using fewer bits while keeping the important information.
Why do image and sound files get so big?
They're stored as extremely long sequences of bits.
Two benefits of compressing a file
It needs less storage space, so more files fit, and it transfers faster: uploading, downloading, streaming and sharing.
What does a compression algorithm do?
It follows a set of steps that makes a file smaller by reducing the number of bits.
What does a decompression algorithm do?
It undoes the compression steps, adding back bits to recreate the data as accurately as possible so the file can be opened, viewed or played.
Lossless compression
No data is permanently lost. It stores repeated patterns more efficiently, and decompressing gives back an identical copy.
Lossy compression
Some data is permanently lost. Decompressing rebuilds an approximation from what's left, never an exact copy.
Does compressing a bitmap image lower its resolution?
No. Compression changes the data, not the file's fundamental properties, so the resolution stays the same.
Does compressing a song make it shorter?
No. A compressed piece of music lasts just as long as the original.
Do you usually have to compress files yourself?
No. If the file format is compressed, compression and decompression happen automatically, like a phone camera saving a JPEG.
Why is lossy used for JPEG photos and MP3 music?
Data can be removed without noticeably affecting quality, because the changes are usually undetectable by the human eye and ear.
Which usually makes the smaller file: lossy or lossless?
Lossy typically produces smaller files than lossless.
When is lossless the better choice?
When data must be fully restored without any loss, such as a document where every character counts or a medical image used for diagnosis.
Three drawbacks of compression
Heavy lossy compression can make audio sound distorted or less clear; editing and re-saving a lossy file can lower its quality further; some equipment may not support certain compressed formats.

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 posted

More KS3 Computer Science topics

See the full KS3 Computer Science curriculum →

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.