In computing, one of the great dilemmas is: is lossy or lossless data compression better? Here’s what they mean and when to use them
Designed at the dawn of computing, when the size of the hard disk was a few tens of megabytes, data compression techniques allow you to save space on the hard disk by modifying the internal structure of multimedia files without (apparently) changing their external appearance.
Over the years, several compression techniques have been created, which can be traced back to the two families “lossy” and “lossless”. This has led to the birth of different file formats for the same multimedia element (JPEG and PNG for images or MP3 and FLAC for audio tracks, for example), giving rise to a sort of Hamletian dilemma: is lossy or lossless compression better? As always, a lot depends on our needs. Only by analyzing in detail what is lossy compression and lossless compression, discovering what are the strong points of both techniques, we will be able to understand which image format or audio format to choose.
What is lossy compression
Also called lossy data compression, lossy compression is a computer technique that allows to compress certain types of files (such as, for example, images, audio tracks or videos) losing, however, part of the original information. In this way, it is possible to recover space on the hard disk, but the quality of the final file has to be lower.
Lossy compression algorithms act on multimedia files by eliminating part of the information that is unnecessary for viewing an image or video. During the compression process, for example, lossy algorithms will eliminate all sounds that are barely audible to the human ear or replace pixels in an image with “neutral” pixels. In short, it will act on the nuances, obtaining a more “homogeneous” file with a greatly reduced size.
Lossy compression at the moment is mainly used in streaming services, on the Internet, for images and multimedia content, and in many applications that we use every day. Once the file has been compressed with this technique, it is no longer possible to recover the deleted data.
Lossless Compression
When we talk about lossless compression, we refer to those algorithms that allow reducing the size of files without, however, any loss of information. The original file and the file resulting from the compression process will therefore be identical (visually, in the case of an image; sonically, in the case of an audio track), but their “footprint” on the hard disk will change.
Unlike lossy algorithms, lossless compression will not eliminate any information, but will allow you to recover space on the hard disk anyway with complex computer techniques. This will make lossless files more difficult for the computer system to “read”: opening a lossless compressed image will take a few seconds longer than opening a lossy compressed image.
What to use
As we said at the beginning, whether or not to use lossless data compression depends on your needs. If, for example, we want to save music and don’t want to occupy too much memory on our device, we might choose an MP3 file (lossy data compression). If, on the other hand, we work in the field of sound editing or need a higher audio quality then we should use a FLAC (Free Lossless Audio Codec) file. And the same goes for JPEG and PNG for images.