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 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

symbols=12original=W W W W W L W B B B B B

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.

1 / 6

Press Next to step. The line to keep your eye on is "same as original?".

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

Watch out: Decompressing a lossy file doesn't bring the removed data back. It rebuilds a best guess from whatever was kept.

Why compress?

?

Reason it through

Why bother compressing files at all?

Link 1 of 4

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?

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 as a JPEG, and you've streamed a song. Both 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; 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.

6 of 6 still to sort.

Place each file where you think it fits best, 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 undetectable by the human ear.

    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

  • 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

1Images and sound need extremely long sequences of bits, and more bits mean more storage space and longer transfers.
2Compression reduces the number of bits while keeping the important information, so more files fit and transfers are faster.
3A compression algorithm makes a file smaller; a decompression algorithm undoes its steps, recreating the data as accurately as possible so the file can be opened, viewed or played.
4Lossless: finds repeated patterns, stores them more efficiently, loses nothing, and decompresses to an identical copy.
5Lossy: permanently removes some data, so decompression only approximates it. Common for JPEG images and MP3 audio, where the changes are usually undetectable.
6Lossy typically makes smaller files, but lossless is the better choice when data must be fully restored, like documents or medical images used for diagnosis.
7Drawbacks: highly compressed audio may 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 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?
Any process that reduces the size of a representation: it cuts the number of bits used for data 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 on a device; and smaller files take less time to upload, download, stream or share.
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, recreating 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. It keeps the same resolution: compression changes how the data is stored, not the number of pixels.
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 JPEGs.
Why is lossy used for JPEG photos and MP3 music?
Data can be removed without noticeably affecting quality: 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 the data must be fully restored without any loss: documents where every character or number counts, or medical images used for diagnosis.
Three drawbacks of compression
Highly compressed audio may 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 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.

Helpful guides for parents and students