Why compress files?
Processing power and storage space is very valuable on a computer. To get the best out of both, it can mean that we need to reduce the file size of text, image and audio data in order to transfer it more quickly and so that it takes up less storage space.
In addition, large files take a lot longer to download or upload which leads to web pages, songs and videos that take longer to load and play when using the internet.
Lossy compression removes some of a file’s original data in order to reduce the file size. This might mean reducing the numbers of colours in an image or reducing the number of samples in a sound file. This can result in a small loss of quality of an image or sound file.
A popular lossy compression method for images is the JPEG, which is why most images on the internet are JPEG images. A popular lossy compression method for sounds is MP3. Once a file has been compressed using lossy compression, the discarded data cannot be retrieved again.
Lossless compression doesn’t reduce the quality of the file at all. No data is lost, so lossless compression allows a file to be recreated exactly as it was when originally created.
There are various algorithms for doing this, usually by looking for patterns in the data that are repeated. Zip files are an example of lossless compression.