In this article we will be comparing the different compression methods available to use within PNG images. To do this, we will be using our Java image library, JDeli. 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.
DEFLATE
DEFLATE was designed in the 1990s and is most commonly using in ZIP file archives due to its lossless property.
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.
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 outputted. 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.