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 JPEG2000, 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:
|PNG||0.168 ± 0.001||NA||0.483 ± 0.001|
|JPEG||6.159 ± 0.013||NA||10.464 ± 0.005|
|GIF||0.063 ± 0.001||NA||0.027 ± 0.001|
|BMP||0.099 ± 0.001||NA||0.026 ± 0.001|
|TIFF||0.014 ± 0.001||NA||0.015 ± 0.001|
|JPEG2000||NA||24.855 ± 0.044||17.528 ± 0.032|
|HEIC||NA||NA||0.085 ± 0.001|
|PNG||0.623 ± 0.006||NA||0.216 ± 0.001|
|JPEG||10.600 ± 0.0.077||NA||5.809 ± 0.011|
|TIFF||NA||11.738 ± 0.050||6.379 ± 0.013|
|GIF||1.078 ± 0.004||NA||2.023 ± 0.014|
|HEIC||NA||NA||0.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.
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.
Start reading and writing images with one line of code
BufferedImage image = JDeli.read(streamOrFile);
JDeli.write(myBufferedImage, OutputFormat.HEIC, outputStreamOrFile)