1.2.5

Compression

Why compression is used and the difference between lossy and lossless compression.

Learning Objectives

  • 1Explain why compression is needed
  • 2Describe lossy compression and its effect on a file
  • 3Describe lossless compression and its effect on a file
  • 4Recommend a suitable type of compression for a given scenario, with reasons

Why compression is needed

Compression means reducing the size of a file. Smaller files take up less storage space and can be sent faster over a network or the internet, for example when streaming a video, sending an email attachment, or downloading a file. Without compression, many files would be too large to store or send efficiently.
Compression reduces a file's size. This matters for two main reasons: it saves storage space (fitting more files onto a device), and it reduces transmission time over a network (streaming, downloading, emailing, or uploading a file all happen faster when the file is smaller).
Compression reduces file size to ease pressure on both storage capacity and network bandwidth. Common scenarios include streaming media, sending large attachments, publishing web content (faster page loads), and backing up large volumes of data. The scenario's requirements, whether any quality loss is acceptable, determine which type of compression should be used.

Think of it like...

Compression is like packing a suitcase efficiently: you fit more in, and it's easier to carry, but depending on how you pack, you might have to fold (and slightly crease) some items to make everything fit.

Lossless compression

Lossless compression reduces file size without losing any data. When the file is decompressed (unpacked), it is restored to be exactly the same as the original, bit for bit. This is essential for files where losing any data would be a problem, such as text documents, code, and spreadsheets. Advantage: no data is ever lost. Disadvantage: because nothing is thrown away, lossless compression cannot reduce file size as much as lossy compression.
Lossless compression reduces file size while keeping all of the original data intact, the file can be decompressed back to an exact copy of the original. This makes it necessary for files where any change would corrupt or alter meaning, such as text files, program code, and spreadsheets. Advantage: the file can always be restored exactly. Disadvantage: it typically achieves a smaller reduction in file size than lossy compression.
Lossless compression is fully reversible: decompression restores the file to be bit-for-bit identical to the original, with no data discarded. It is required wherever data integrity is essential, text, code and spreadsheets cannot tolerate any alteration, since even a single changed character or value could corrupt the file or its meaning. The advantage of guaranteed exact restoration comes with the disadvantage of a smaller compression ratio compared with lossy methods (you are not required to know the specific algorithms used).

Lossy compression

Lossy compression reduces file size by permanently removing some data, usually detail that is hard for humans to notice, such as very subtle colour differences in an image or sounds outside the range most people can hear. Once compressed this way, the removed data cannot be recovered. Advantage: it gives a much smaller file size. Disadvantage: some quality is permanently lost, so it isn't suitable for everything.
Lossy compression permanently discards some data to achieve a much greater reduction in file size than lossless compression. The data removed is chosen because it is least noticeable, such as fine detail in images or high/low frequencies in sound. Advantage: it achieves a much smaller file size than lossless. Disadvantage: the removed data can never be recovered, so it is unsuitable for files like text or code, where the exact original data must be preserved.
Lossy compression irreversibly discards data judged least perceptible to a human, once compressed, the original cannot be exactly reconstructed. The advantage is a significantly greater size reduction than lossless compression, which is why it dominates for media formats (images, audio, video) where some quality loss is an acceptable trade-off for smaller files and faster streaming/transfer. The disadvantage is that it is not appropriate for data that must remain exact, such as text or executable code.
LosslessNo data lost, exact restoreSmaller size reductionUsed for text & code(accuracy matters)LossyData permanently removedMuch greater size reductionUsed for images, audio, video(small quality loss OK)

Choosing the right type of compression

Exam questions often give you a scenario and ask you to recommend lossy or lossless compression, and to justify why. The key question is: can any quality loss be tolerated? If not (text, code, important data), choose lossless. If a small quality loss would not be noticed (photos, music, video for streaming), lossy is usually better since it reduces the file size much more.
When recommending a compression type: ask whether the file can tolerate any loss of data. Text, program code and files where accuracy is essential need lossless. Images, audio and video, where a human is unlikely to notice small changes, are usually better suited to lossy, since it achieves a much greater size reduction. Always justify why the type is appropriate for that specific scenario, not just describe how compression works in general.
A strong justification names the compression type and links it explicitly to the scenario's tolerance for data loss and its size/speed requirements, for example "lossy is appropriate here because the small loss in audio quality would not be noticed by a listener, and the much greater reduction in file size means the podcast streams faster." A common exam error is describing how a type of compression works instead of justifying why it suits the given context, this earns no marks for a "recommend and justify" question.

Exam Phrasing: Use These Exact Phrases

  • ✓Compression reduces file size, saving storage space and reducing transmission time
  • ✓Lossless compression removes no data; the file can be restored exactly to its original
  • ✓Lossy compression permanently removes some data to achieve a greater reduction in file size
  • ✓Lossless compression is required for files like text and code, where no data can be lost
  • ✓Lossy compression is suitable for images, audio and video, where a small quality loss is not noticeable
  • ✓Advantage of lossless: no data is lost. Disadvantage: smaller reduction in file size
  • ✓Advantage of lossy: much greater reduction in file size. Disadvantage: data is permanently lost
  • 💡If a question asks for an advantage and a disadvantage of a compression type, give one clear point for each, don't just describe the type in general.
  • 💡For "recommend and justify" questions, always explain why a compression type suits the scenario, not how compression works, examiners specifically flagged this as a common way to lose marks.
  • 💡Text and code files always need lossless compression, since any change could corrupt the file or alter its meaning.
  • 💡If a scenario mentions streaming, storage limits, or "quality loss would not be noticed", that points towards lossy compression.
  • 💡You don't need to know how any specific compression algorithm works, focus on the difference in effect on the file (data lost or not) and when each type is appropriate.

Wrong:

Describing how a type of compression works instead of justifying why it suits the scenario

Right:

Explain why the type of compression is appropriate for the specific scenario given

Why it matters: OCR examiners noted this is a common way candidates lose marks on "recommend and justify" compression questions.

Wrong:

Using lossy compression for a text document

Right:

Use lossless compression for text, since losing data could corrupt the document or change its meaning

Why it matters: Text files require every character to be preserved exactly, lossy compression is not appropriate.

Wrong:

Lossless compression always reduces file size more than lossy

Right:

Lossy compression achieves a much greater reduction in file size than lossless, because it permanently discards data

Why it matters: It's the opposite way round, lossless keeps all the data, so it can't shrink the file as much as lossy can.

Question:

A music streaming app compresses songs before sending them to users. Recommend whether lossy or lossless compression should be used, and justify your answer. [3]

💡 Attempt this before revealing the answer, practice makes perfect!

Model Answer:

Lossy compression should be used. This is because it achieves a much greater reduction in file size than lossless compression, meaning songs can stream faster and use less data. A small loss in audio quality from lossy compression is unlikely to be noticed by most listeners, so the trade-off is worthwhile.

Mark Scheme:

  • 1Identifies lossy compression
  • 2Justifies with greater file size reduction, allowing faster streaming/less data use
  • 3Justifies with the small quality loss being acceptable/unlikely to be noticed

Tap a card to flip it. Use the arrow keys to move and space to flip.

Known 0 Still learning 0
1 / 12

Exam-style questions. Have a go, then reveal the mark scheme to check your answer.

1.State one reason why compression is used.

[1]

2.State the difference between lossy and lossless compression.

[2]

3.A student is emailing a Word document containing coursework text to their teacher. Recommend a type of compression and justify your answer.

[2]

4.A photographer wants to upload holiday photos to a website, and file size is more important to them than perfect image quality. Recommend a type of compression and justify your answer.

[2]

5.Explain why lossless compression is not usually suitable for streaming music to many users at once.

[3]

6.A photographer stores original images and also emails previews to clients. Discuss whether they should use lossy or lossless compression.

[8]

Extended response · marked in levels, not by counting points

The examiners' reports are the most useful and least read of the three: they say what candidates actually got wrong each year. All files are hosted by OCR.

Past-paper questions grouped by topic

The same OCR questions, sorted by topic rather than by year (via Physics & Maths Tutor).

2023
Paper 1

On a question about compressing a text file, most candidates correctly identified lossless compression. Stronger answers justified this either by explaining why lossless suits text, or by explaining why lossy would not be appropriate.

Paper 1

On a question about compressing an image or audio file, many candidates correctly recommended lossy compression, explaining that the loss of data would not be noticed and that it reduces file size more. Candidates who chose lossless sometimes struggled to justify their choice appropriately.

Paper 1

A general pattern noted across "recommend and justify" style questions: some candidates gave a choice but described how that method works rather than explaining why it was the most appropriate choice for the given context. Only the "why" earns justification marks.