CIE AS & A Level Computer Science, section 1.3 (Compression)
Why compress files?
Compression reduces the size of a file. This means:
- the file takes up less storage space,
- it can be transmitted faster and uses less bandwidth,
- it needs less memory to open and work with.
Examples: sending photographs by email, streaming video and music, and storing many files on a device.
Lossless compression
With lossless compression, the original data can be perfectly rebuilt. No information is lost.
- Used where every bit matters: text documents, program files, spreadsheets and some images.
- Examples: ZIP files, PNG images, and run-length encoding.
- The file size is reduced less than with lossy methods.
Lossy compression
With lossy compression, some data is permanently removed, usually the parts people are least likely to notice. The original cannot be fully recovered.
- Used for photographs, music and video, where a small loss of quality is acceptable.
- Examples: JPEG images, MP3 audio and MPEG video.
- Much greater reduction in file size, but quality is lower. Repeated compression makes quality worse.
| Lossless | Lossy | |
|---|---|---|
| Original recovered? | Yes, exactly | No |
| Typical size reduction | Smaller | Larger |
| Suitable for | text, programs, medical images | photos, music, video |
Justifying a choice
Link the type of file to the method. A bank statement (text) must be stored losslessly, because changing even one character would change the data. A holiday photo for a website can use lossy compression to load quickly.
Common mistake: saying lossless compression "removes redundant data so it can't be recovered". It removes redundancy in a way that can be reversed. Only lossy compression discards data permanently.
Exam tip: in a justify question, name the file type, the compression type, and a reason in context (accuracy of the data, file size or transmission time).
Check yourself
Give two reasons for compressing a file.
It uses less storage space, and it can be transmitted faster.
Which type of compression is suitable for a text file?
Lossless, because the original text must be recovered exactly.
Why can a file compressed with lossy compression not be restored exactly?
Some data is permanently removed during compression.