Are you a Java Developer working with Image files?

Read and write images in Java with JDeli

Comparing PNG Compression Algorithms

49 sec read

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.



Find out how to read and write images files in Java with JDeli:

Read: BufferedImage image = JDeli.read(streamOrFile);

Write: JDeli.write(myBufferedImage, OutputFormat.HEIC, outputStreamOrFile)

Learn more >>

What is JBIG2?

JBIG2 is a lossless and lossy compression standard for bi-level images like scanned documents, offering high compression ratios by identifying and encoding similar shapes...
chika
47 sec read

Dependabot and other dependency update tools

What are auto dependency update tools? Automatic Dependancy update tools are used to monitor your dependencies, by checking the semantic versioning of your dependencies...
Amy Pearson
1 min read