DEV Community

IDRSolutions
IDRSolutions

Posted on

Comparing PNG Compression Algorithms

In this article, we will be comparing the different compression methods available for use in PNG images. To do this, we will be using our Java image library, JDeli. JDeli is the best pure Java image library for performance and efficiency. We will be comparing against file size, quality of output, and speed.

For the baseline of our comparisons, we will be using the following image. It has a file size of 39.3MB and takes just under 5 seconds to encode.

PNG example image

DEFLATE

DEFLATE was designed in the 1990s and is most commonly using in ZIP file archives due to its lossless property.

Deflate PNG example

Using DEFLATE, the file size is reduced to 5.1MB taking around 6 seconds to encode. Since DEFLATE is lossless, the image quality is preserved and matches the original file.

QUANTISE

QUANTISE is a lossy compression technique that reduces file size by limiting the range of available colours. It is commonly used in PNG and GIF images.

Quantise PNG example

Using QUANTISE, the file size is reduced to 3.5MB. QUANTISE is lossy, so there is a reduction in image quality, most noticeably in the range of colours which are output. It also takes around 6 seconds to encode.

Conclusion

In conclusion, there are not a great deal of options when it comes to different compression algorithms in PNG files. DEFLATE is a clear winner here as it reduces the file size with no loss of quality. QUANTISE would only be better when the smallest possible file size is necessary.

As experienced Java developers, we help you work with images in Java and bring over a decade of hands-on experience with many image file formats.

Top comments (0)