Lossy vs lossless image compression

Table of Contents
image of binary charters on a screen with a red heart shape in the middle.
Photo by Alexander Sinn on Unsplash

If you were wondering what the difference was between lossy and lossless image compression, you’ve come to the right place. We’ll provide a quick overview of both types of compression

What is lossy image compression?

In a lossless compression algorithm data which is deemed to not be required is removed from the image, hence lossy. This means the original quality can’t be recreated from the lossy compressed version and the quality is reduced.

Photographs lend themselves very well to lossy compression algorithms as there’s usually a high amount of data that can be compressed and lost before there is a noticeable degradation to the image quality. The output is usually significantly smaller than the original image.

JPEG is one of the most common lossy image compression algorithms. It compresses images by looking for similar pixels. The algorithm then replaces similar pixels with a representative colour that is found in the rest of the image. This results in smaller file size but with reduced visual quality. When a JPEG image is opened in an image editor, the image can be edited like any other image. However, when the image is saved, it is re-compressed. This results in JPEG artifacts. These are slight visual disturbances that are most noticeable in areas of high visual complexity.

What is lossless image compression?

In contrast, in lossless image compression, none of the original detail is lost. Unfortunately, that also means there isn’t a huge reduction in the file size.

Most lossless image formats are either raw photo formats (like .ARW for Sony cameras) or use a non-lossy format like PNG or GIF. The advantage of lossless image formats is that they can be edited and resaved over and over without any quality loss. The downside is that they tend to be larger than their lossy counterparts.

Where lossless image compression excels in graphics with fewer colours and less complexity compared to say a photo. So for example, a logo would be a great type of file to compress with a lossless image compression algorithm.

PNG is an example of a lossless image compression algorithm. When this algorithm is applied, pixel colour values are examined and compared to each other. If the pixel values are very similar, the algorithm stores only one value and uses a reference to the other value in the image. When the image is opened and edited in an image editor, the original pixel values are used. This results in images that don’t show any visual difference when saved.

Is it time for a better WordPress host?

You might also like..

Are you wasting money on your current hosting provider?

Related Posts