Compression is used to reduce file sizes – something which is essential in an era of online video streaming and media sharing.
Without compression, we would:
- Fit less music, videos or photos onto your smart phone or computer
- Struggle to stream or download videos from the internet
- Struggle to upload media to the internet
- Find browsing websites a slower experience
Compression can be categorised as either lossy or lossless.
Lossless compression reduces the size of a file without any damage to the file or reduction in quality.
The file can be decompressed to its original state, with all the data bits reconstructed.
Lossless compression is ideal for compressing text or numeric files where a loss of data is unacceptable. It is also used in PNG, GIF and ZIP files.
How does lossless compression work?
- Lossless compression takes advantage of repetition and patterns.
- A compression algorithm is used to find and index repeated words or patterns (or sections of words) within the data.
- Wherever they occur in the data, the indexed words/patterns are replaced with numerical values.
- The index will need to be stored with the data to allow decompression with no loss of data.
To get low file sizes, lossy compression permanently removes data from the file that the computer believes you can do without (redundant data).
Often we can hardly notice the difference, but if you get too greedy (aggressive) with lossy compression you will notice the file quality deteriorates significantly.
It is impossible to get the file back to its original state and quality. Lossy compression is best at creating really small file sizes – ideal for downloads or streaming.