LightMySky
En anglais

Compression: Lossy and Lossless

Making a file smaller either by storing the same information in fewer bits, or by dropping detail people are unlikely to miss. Which of the two is safe depends on the file.

No account needed. Progress saves in this browser.

What a learner can do afterwards

  • Describe a lossless method, such as recording runs of repeated values
  • Explain what lossy compression throws away and why it cannot be put back
  • Choose the right kind for a photo, a song and a file of code

1 · Read

Compression makes a file smaller. Lossless compression stores the same information in fewer bits, so every bit comes back when the file is opened. ZIP files and PNG images work this way. Lossy compression drops detail people are unlikely to notice. The dropped detail is not stored anywhere, so it can never be put back.

Try it together

Run-length encoding is one lossless method. In a picture where 0 is a white pixel and 1 is a black pixel, it counts runs of the same colour. Counts alternate white, black, white, and always start with white. The row 0000110001111100 becomes 4, 2, 3, 5, 2. A row that opens with black starts with a 0 count, so 1110000000000011 becomes 0, 3, 11, 2. Reading the counts back rebuilds the row exactly.

0000110001111100

Lossy compression uses the limits of eyes and ears. Eyes notice changes in brightness more than changes in colour, so colour can be averaged over small blocks. A loud drum beat hides quieter sound from about 20 ms before it to up to 200 ms after it, so that hidden sound can be dropped. Each lossy re-save drops more detail, so keep a lossless master and export copies from it.

Match the kind to the file. A photo or a song can lose detail people barely notice, so lossy suits sharing them. Text, code and spreadsheets change meaning if one bit changes, so they need lossless.

Lossless packs repeats and returns every bit. Lossy drops hidden detail for good. Choose by whether the file must come back whole.

Lesson text, worked examples, flashcards and practice questions with worked steps, written for this dataset. Facts on masking times follow the academy article Lossy compression.

2 · Watch

En anglais

Take it off screen

Print a worksheetA4 with an answer key page for grown-ups. No screen, no internet.

Where it sits

Then practise

8 questions wait behind this lesson, each with its answer explained. Every answer feeds the sky: stars light as they are learned, and dim when it is time to come back.

Spotted a problem on this page? Tell us
Compression: Lossy and Lossless · Computing, ages 15 to 16 · LightMySky