Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

How does Java handle different Images and ColorSpaces – Part 4 ImageIO and other image libraries

1 min read

Unless you are creating all your images, by drawing then inside the code with the Graphics2D commands, you will need an image library to load images as BufferedImages. You will also need an Image library if you wish to save the results.

ImageIO is part of Java, it is free and it supports a range of Image formats including GIF, JPEG, PNG, and TIF. Because it is expandable, there are additional libraries to extend it. We recommend you check out the excellent TwelveMonkeys image library which is free and Open Source.

ImageIO does have some limitations which can be summed up as:-

1. Could have better support for some image file formats.

JPEG/JPEG2000 support in ImageIO is not as good as it could be and the main reason we started writing our own Image library.

2. Does not support Image file formats

There are lots of image formats which ImageIO will not read and write.

3. Memory issues and Bugs

ImageIO uses native memory so it runs out of memory even if there is lots of Java heap. This can be a big issue with server software being shared between multiple users.

Alternatives?

Luckily there are options. Below we give you some reasons to use the excellent Open Source Apache Imaging library or own commercial JDeli image library. We think they provide the two best options if you need something more than ImageIO. Which one is best will depend on your exact requirements.

Why use Apache Imaging Library?

  • Free and Open source
  • prevents heap related JVM crashes
  • Very wide range of image formats (but not JPEG2000)
  • implements unsupported image formats in ImageIO
  • reduced output file size over ImageIO
  • Source code under Apache license.

Visit the Apache Commons Imaging library

Why use JDeli?

If you are working with Images in Java, JDeli offers a range of advantages over ImageIO and alternatives, including:

  • support provided
  • prevents heap related JVM crashes
  • excellent JPEG/JPEG2000 support
  • includes the new Heif image format from Apple
  • implements unsupported image formats in ImageIO
  • reduced output file size over ImageIO
  • better read/write performance

Learn more about JDeli, or download to try it yourself.

In previous articles on this series, we have talked about How Java works with Buffered Image,the ColorSpace class and the different types of BufferedImage and how they can be converted into ColorSpace.

Did you know...

IDRsolutions offers a whole range of online file converters to convert PDF and Microsoft Excel, Word and Office Documents to HTML5, SVG or image formats?

It is free to use for single file conversions and also includes Developer links if you want to use our commercial software for bulk conversions. Find out more on this page

Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

How to read HEIC image files in Java with…

In this article, I will explain how to read HEIC files into Java as a BufferedImage. ImageIO does not read HEIC file types so...
Mark Stephens
1 min read

How to convert WMF files to SVG in java…

This article will show you how to convert WMF files into SVG files using our JDeli Java Image library. What is WMF? WMF is...
Amy Pearson
1 min read

How to write WebP images in Java

In this article, I will walk you through how to write out images as WebP images in Java. ImageIO does not support WebP images...
Mark Stephens
1 min read

Leave a Reply

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

IDRsolutions Ltd 2020. All rights reserved.