Monday, August 3, 2009

Java ImageIO and GIF

I'm working on a project where users can upload images in JPEG, PNG and GIF formats and we resize the images using Java's built-in ImageIO API. Unfotunately, there's some confusing issues with GIF support. Using Java 1.5, GIF images can easily be read, but writing GIFs is not supported. This apparently has to do with CompuServe's patent on the GIF format.

The good news is that the patent recently ran out, so we can now freely write images to GIF format with ImageIO.

We have two simple options to make this work--either upgrade our project to Java 1.6 or include a plugin JAR that adds GIF support (for example com.sun.imageio.plugins.gif for Java 1.4 and above).

References: