Data Compression

Data compression is a term used to describe reducing the size of a file whilst keeping it in a usable format. There would be little point in making a file smaller if we could no longer use it, so different algorithms have been developed to allow us to make efficient use of space on our digital devices.

Compression techniques can be categorised into two methods:

Lossy – data is removed from the original file to reduce its size.

Lossless – data is not removed from the original file, or can be restored in full.

Lossy Compression

Lossy compression can be applied to files where losing data may not be detected, or if it is, the file is still usable. This generally means that images, video, and sound use lossy compression techniques (but not always!).

When you are watching a streamed video, you will often be given the choice of watching in HD or SD. Whilst we know the Standard Definition video is of inferior quality, it does have the benefits of being a much smaller file so it will work on slower connections. Even though the file is of a lower quality (due to lossy compression), it remains usable.

JPEG image files use a lossy compression technique where the number of colours in the image are reduced to just those within the human spectrum of vision. Often, the number of colours is reduced to far less without a visible difference. In the case of JPEG files, the removal of colours is balanced by replacing the standard RGB (red green blue) colours with luma (brightness & contrast) & chroma (red – blue colour).

Lossless Compression

Lossless compression is employed when we need to reduce the size of the file without losing any data. This may be because removing data would make the file unusable as is the case for text files or program code, or to allow us to uncompress the file back to it’s original state for editing.

Zipped files make use of lossless compression, allowing the files & folders to be uncompressed after sending without losing data. Compressing data, can be acheived using a variety of algorithms, one being Huffman Encoding which reduces the number of characters and makes efficient use of bit patterns.

Another technique that can be applied to both text and images is known as Run Length Encoding. In RLE, pixels or characters that are the same are encoded as a run instead of idividually. For example:

Uncompressed Text:  HAAAHAAAHAAA 

RLE: H1 A3 H1 A3 H1 A3

Try this for yourself be using the RLE generator below:

Type in some text with duplicate value, work out your RLE & check your result!

Find this page helpful? Share the love on your social media mentioning @TeachAllAboutIT and we’ll enter you in our monthly draw to win a gift voucher for any product on the site!

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest
Share on whatsapp

Looking For More?

Resources may be purchased individually, or accessed through subscription

Not a member yet? Sign Up

Or Sign In to access resources on this page Notes

Huffman Encoding is only required for students studying the AQA syllabus. This is a large part of the Data Compression area of the topic.

The Huffman Encoding & Data Compression Notes provide a structured way for students to revise topic areas covered in class in a visual way. Encourage students to colour in areas of importance, add doodles and colour, then add more detail to the notes page being as creative as possible.

There are known benefits to using Notes (whether structured like these, or independently created):

  • Increased Attention
  • Reduction of stress levels
  • Increased memory for content
  • Deeper learning

Scroll to the bottom to download

Data Compression

Huffman Encoding

Test your knowledge with the Compression Techniques (Lossy & Lossless) – Full quiz!

Click the next button to start the quiz. Questions are shown one at a time.

1. Why would you compress a file?
2. What type of compression doesn’t reduce the quality of file at all?
3. What is compression in computing?
4. What type of compression allows the file to be recreated exactly as it was when it was originally created?
5. Which type of encryption is best for space saving?
6. What type of compression removes some of a file’s original data in order to reduce file size?
7. What type of encryption does a ZIP file use?
8. A JPEG uses what type of compression?
9. What is a pixel?
10. What are the two main types of data compression?

Enter your name and email below to be sent a copy of your results.

Your data will only be used for the purposes of sending your quiz results – for more information about the privacy of your data, please read our GDPR policy

Hover over the flashcard to reveal the answer!