Mark Stephens Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Why we are abandoning ImageIO and JAI for Image support in our commercial Java code

1 min read

jpeg-icon

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 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. Our PNGEncoder is at least twice as fast as ImageIO, and it offers much better support for Tiff, JPEG and JPEG2000. It also supports additional image formats such as DICOM, PSD, SGI and WEBP. Moving to our own image library will allow us to:

  1. Substantially improve speed and memory usage in our commercial products
  2. Easily fix issues in image out
  3. Add new features (like being able to easily down-sample PNG to indexed PNG

We have made this available as a separate download which is free to download and use (you will need to pay to ship it with any products).

So what is your experience of image support in Java. Are you still using JAI and ImageIO or implementing your own solution?

IDRsolutions develop a Java PDF Viewer and SDK, an Adobe forms to HTML5 forms converter, a PDF to HTML5 converter and a Java ImageIO replacement. On the blog our team post anything interesting they learn about.

Mark Stephens Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

13 Replies to “Why we are abandoning ImageIO and JAI for Image…”

      1. May I just suggest — since you enjoyed the community’s efforts for over a decade — that you contribute that image library back to the community? Seems only fair.

        1. We contributed a JBIG2 decoder library for Java under a BSD license (which most of our competitors use) and submitted numerous fixes for JAI. (and we are currently organising a big Java community event in UK in May). So we are active contributors to the community….

          There is an interesting Open source library for PNG from Google if you are looking for an OS solution (https://code.google.com/p/pngj/).

        1. At the moment we are just trying to fill a need in our code and thought it would make an interesting item for a blog article for other users wrestling with the issue of image support in Java. All options are on the table in future.

  1. I am using twelvemonkeys ImageIO. The result is acceptance. Why you don’t release ur library. I wanna try yours.

  2. (I’m the author of the TwelveMonkeys ImageIO library that @Nguyen mentions. I’m just about to release the 3.1 version of my library, with a greatly improved and more robust JPEG reader, along with other new features such as baseline TIFF write support etc., in case you were interested).

    Having a BSD-licensed pure Java JPEG (especially if it supported arithmetic coding, lossless and other non-baseline stuff) or JPEG2000 ImageReader would be a great thing! If you would contribute it to the project, you could have all my other format support for free (ok, you can have it anyway, it’s BSD licensed, I’m just trying to sweeten the deal a little.. 😉 )!

    Anyway, keep up the good work!

    .k

    1. Hi Harald,

      Great to hear about the new release and we will try to help promote it. The Java world needs alternatives to ImageIO! At the moment we are just trying to fix an issue which is a major headache for our customers. Once we have it fully working we will consider future plans.

Leave a Reply

Your email address will not be published. Required fields are marked *