At IDRsolutions, we are now using our own Java Image Library (JDeli) as a replacement for ImageIO and JAI. We had previously been using ImageIO and JAI to handle image data and write out BufferedImages as PNGs, JPEGs or Tiff and for decoding some image data inside PDF files since we started writing our Java PDF library in 1999.
However, this has become an increasingly frustrating and unsatisfactory solution for us 🙁
JAI has long been abandoned by Oracle (we have actually put out several tips and patches for JAI JPEG2000 bugs on our blog) which offers no alternative way to load JPEG2000 files in Java. The JPEG2000 implementation was never completed and is slow, memory-intensive, and does not handle lots of JPEG2000 files.
ImageIO has seen little improvement in recent Java releases, despite being the only way to load and save Images in Java. Indeed is it still needed in the new JavaFX code to load and save images. It also represents a big black box in our PDF to Image solution which we have no control over. So we have been busy writing our own Java image library (JDeli), and now use this instead of JAI or ImageIO.
Why use JDeli?
JDeli offers a range of advantages over ImageIO and alternatives, including:
- prevents heap related JVM crashes
- implements unsupported image formats
- reduce the output file size
- improve read/write performance
- supports threading
- superior image scaling algorithms
So what is your experience of image support in Java? Are you still using JAI and ImageIO or have you tried JDeli?
Read and write images in Java with one line of code
Read an Image with
BufferedImage image = JDeli.read(streamOrFile);
and write an Image with
JDeli.write(myBufferedImage, OutputFormat.HEIC, outputStreamOrFile)