fbpx

Is The PNG Format Lossless Since It Has A Compression – Sem Seo 4 You

The PNG format is supposed to be a lossless format, but when you save an image as a PNG file, you are asked to choose a compression level. Does this mean that the PNG format is actually not lossless after all? Today’s SuperUser Q&A post helps clear up the confusion for a curious reader.

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

The Question

SuperUser reader pkout wants to know if the quality of a PNG image is affected by the compression level chosen:

As I understand it, PNG files use lossless compression. However, when I am using an image editor such as Gimp and try to save an image as a PNG file, it asks for a compression level ranging between 0 and 9.

If it has a compression parameter that affects the visual precision of the compressed image, how is PNG lossless then? Can someone please explain this to me? Do I get lossless behavior only when I set the compression level to 9?

Is there a difference in the quality of the image depending on the compression level you choose?

The Answer

SuperUser contributors LordNeckbeard and jjlin have the answer for us. First up, LordNeckbeard:

PNG is Compressed, but Lossless

The compression level is a trade-off between file size and encoding/decoding speed. To overly generalize, even non-image formats such as FLAC have similar concepts.

Different Compression Levels, Same Decoded Output

Although the file sizes are different due the the different compression levels, the actual decoded output will be identical. You can compare the MD5 hashes of the decoded outputs with ffmpeg using the MD5 muxer. This is best shown with some examples.

Create PNG Files

how-is-the-png-format-lossless-since-it-has-a-compression-parameter-01

Share on Whatsapp

Leave a Comment

Your email address will not be published. Required fields are marked *

Translate »
Enable Notifications    OK No thanks