English ▼

Lossy Compression

Lossy compression is a method used by image, video, audio, and other media formats as a means to reduce the size of a particular file. It does this by discarding data that would likely go unnoticed in order to simplify the file content, which enables more efficient encoding and thus reduces the size of the final saved file.

The opposite of lossy compression is, of course, lossless compression, in which file data is compressed using methods that will not result in any loss of detail. We go into non-lossy compression here.

Why would you care about the file size I here you say. Smaller file sizes mean less storage space is needed to store the file, and less bandwidth is needed if you need to upload or email the file.

Lossy Image Compression

An example of lossy file compression is the well-known image format JPEG. When an image is saved in this format, similar parts of the image are identified and stored in a way that doesn't duplicate them, saving large amounts of space in the process. Considerable savings can be made within any color photographic image, as there are many thousands of colors, many of which are very similar, and some of these similar colors can be discarded.

To compare how much an image file can be compressed using this process, we can inspect a photo taken with an average 12-megapixel camera whose pixel resolution is around 4080x3072. Saved as a JPEG, this file comes in at around 2mb, If this file were saved in a raw, uncompressed 24-bit RGB format, the file size would be around 36Mb.

Here we have an image saved at different compression settings. The first image is saved at the default setting that maximizes quality, the second image at 50%, and the final image at 90%, resulting in the smallest file size. Can you spot the difference? With some photo images, it can be hard to see the reduction in quality, which is a testament to how good the compression algorithm really is.

A rain chain with a low compression setting (517Kb)

A rain chain with a low compression setting (517Kb)

The same image with a 50% compression setting (140Kb)

The same image with a 50% compression setting (140Kb)

The same image with a 90% compression setting (46Kb)

The same image with a 90% compression setting (46Kb)

While compressing photos using the JPEG compression method leads to great results, you may not get the same results for other types of images. In particular, images containing crisp edges or contrasting colors in close proximity tend to look worse. Examples of these images, such as company logos and video game art, are some of the image types that do not work well with lossy compression methods like JPEG.

Here we have a piece of videogame pixel art; the original image on the left is saved as a PNG, which utilizes lossless compression. The second image is saved as a JPEG using a 50% compression setting, with the image on the right using a 90% compression setting. Not only do we see blurring/bleeding together of the crisp and contrasting colors, leading to a visibly poorer representation of the original image, but the file sizes are actually much larger for the JPEG versions than the original PNG image. This illustrates the importance of choosing the correct file format for the type of image you are creating. Lossy compression-based formats, such as JPEG, are not suitable for all images.

Some video game art in its original PNG format (12Kb)

Some video game art in its original PNG format (12Kb)

The same game art with a 50% compression setting (55Kb)

The same game art with a 50% compression setting (55Kb)

The same game art with a 90% compression setting (23Kb)

The same game art with a 90% compression setting (23Kb)

Lossy Audio Compression

With audio files, the most common method of lossy compression is Psychoacoustics, in which audio contained within the sound file is analyzed and certain sounds that would not be audible to the human ear are removed. This can yield substantial savings in file sizes without the listener noticing any loss of quality.

An example of the kinds of savings to be made can be seen with audio stored on a compact disc (CD). A typical CD can hold 80 minutes of audio, amounting to around 700Mb of data. To ensure the greatest listening experience, this audio is stored in a high-quality, uncompressed format.

If you converted that 80 minutes of audio into a medium-quality (128kbps) MP3 file, the resulting file would be around 74Mb.

Lossy Video Compression

Compression techniques used within movie file formats such as MPEG take the lossy image compression described previously for JPEG files to the logical next step, which is to not only remove duplicate elements of each frame but also remove repeated sequences between the individual frames of the movie. This level of compression, if done at a reasonable compression setting, results in a video file with no noticeable loss in detail. Along with image compression, audio within a typical MPEG video file is compressed using MP3 compression, making the MPEG format optimal for storing video files.

For more information on lossy compression, please see this article which goes into greater detail than we have covered here.

© 2024 ImageToStl. Convert your PNG and JPG Files to 3D STL files.

Your files are ready to download!