Amy Pearson Amy is a Java developer and member of the support team. Her main technical interests are JavaFX and Cloud. Out of hours she enjoys gaming and Virtual reality.

Java Image Library speed comparison: JDeli and ImageIO/JAI

1 min read

Java image library speed comparison

Back in 2017, we compared the speed of our Java Image Library JDeli with ImageIO and JAI and had some interesting finding. Now we are back to see how we compare not only to other libraries but our improvements over the years. The obvious improvement is the additional support for formats such as reading and writing for HEIC and GIF, writing for JPEG 2000, and reading for WMF and EMF. But we also want to see the speed improvements for our handling of formats.

How did we make the speed comparison tests?

We will be using Java Microbenchmark Harness to test our library’s performance against ImageIO and JAI, as we have found it yields more accurate testing. If you want to know how you can get testing, we have an article on How to test image performance of Java libraries with JMH and IDEA IDE.

The code we used for testing is on GitHub, and the tests will happily run on the trial version if you want to carry out your own tests. We would love you to run them on your own image file datasets/hardware and let us know the results!

Running the tests

First, we want to make sure we are testing formats that are supported by both JDeli and ImageIO/JAI. So we won’t be including DICOM, EMF, HEIC, PSD, SGI, WEBP, WMF.

I have separately included HEIC for both reading and writing, despite no other libraries currently supporting it. I am interested in seeing the speed of our new format that our team has worked hard on, and I thought you guys might find it interesting too.

As we want to compare the speed, we will be using the average time mode. This will take the average seconds per operation. For all of these tests, we will be using a directory of 50 files to load the image into Java as a BufferedImage. For each test, I have highlighted the best result in green.

Let’s look at the scores:

Reading

File TypesImageIOImageIO/JAIJDeli
PNG0.168 ± 0.001NA0.483 ± 0.001
JPEG6.159 ± 0.013NA10.464 ± 0.005
GIF0.063 ± 0.001NA0.027 ± 0.001
BMP0.099 ± 0.001NA0.026 ± 0.001
TIFF0.014 ± 0.001NA0.015 ± 0.001
JPEG 2000NA24.855 ± 0.04417.528 ± 0.032

 

HEICNANA0.085 ± 0.001

Writing

File TypeImageIOImageIO/JAIJDeli
PNG0.623 ± 0.006NA0.216 ± 0.001
JPEG10.600 ± 0.0.077NA5.809 ± 0.011
TIFFNA11.738 ± 0.0506.379 ± 0.013
GIF1.078 ± 0.004NA2.023 ± 0.014

 

HEICNANA0.297 ± 0.001

Because JDeli has several compression options for PNG and TIFF, I have set the compression to our option optimised for speed. Both libraries have different options for prioritising speed or image quality, so the tests compare the speed using equivalent quality settings.

Conclusion

JDeli fixes many of ImageIOs bugs and can handle more files and file formats. When testing I found for some files Exceptions were thrown for ImageIO so to keep the tests fair I removed these files and replaced them with files that could be handled by both libraries.

Choosing the best Java image library for your use case is important, and here we are comparing only speed for Comparable image quality. There are many metrics that can be compared including file size, quality, formats supported, etc.

If you are interested in our JMH tests, we also have more test results on our support site.



Are you a Java Developer working with Image files?

Why do developers choose JDeli over free alternatives?

  1. Works with newer image formats such as AVIF, HEIC, JPEG XL, WEBP
  2. Better support than alternatives for JPEG, PNG, TIFF.
  3. Prevent JVM crashes caused by native code in other image libraries
  4. Better performance than other popular Java image libraries
Amy Pearson Amy is a Java developer and member of the support team. Her main technical interests are JavaFX and Cloud. Out of hours she enjoys gaming and Virtual reality.

What is JPEG XL?

Amy Pearson
1 min read

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...
Amy Pearson
55 sec read