NOTE: This is not an attempt to backport the entire imageio package from Java 6. Only the parts we need to write a GIF file to an outputstream.

FOR ALL OTHER IMAGE OPERATIONS YOU MUST USE THE javax.imageio PACKAGE THAT SHIPS WITH JAVA 5.

Introduction

Java 5 supports reading GIF files. Java 6 also supports writing GIF files. I needed a nice way to write gif images from Java 5. A lot of GIF packages exists for Java 5. But most of them does not give the same nice result as the implementation by Sun. Since I couldn't upgrade to Java 6 in my project, I backported parts of the javax.imageio package from openjdk-6-src-b09-11_apr_2008 (Can be downloaded from http://openjdk.java.net), so that it can run on Java 5. I've introduced new package names, so that this package will not mess with the standard javax.imageio package. Feel free to use it. But remember that it comes with no guarantees! If you find any problems you can mail me at java6-gif-backport/at/jakobielsen_dot_net.

Thank's to the OpenJDK project for great image software! I'm really looking forward to the day when I will not need this port anymore. :)

I have tried to release this project according to GPL v.2.0. Please let me know if I have broken any of the "rules" in there.

Example of use :

...
import net.jakobnielsen.imageio.ImageIO;
...
public void encode(BufferedImage image, OutputStream out) IOException {
  // Try that in standard Java 5 ;)
  ImageIO.write(image, "GIF", out);
}
...

Please let me know if you start using this code, or find any bugs!

Jakob Vad Nielsen

Source code

You will find the source code in the download area as a jar file. Be sure to read the license before doing any changes to it.

How to use this package with Maven 2

First of all you will have to add this maven repo to you pom:

<repositories>
  ...
  <repository>
    <id>jakobnielsen-mirror</id>
    <name>JakobNielsen Maven Repository</name>
    <url>http://maven2.jakobnielsen.net/</url>
  </repository>
  ...
</repositories>

Then you must add this dependency to your pom:

<dependency>
  <groupId>net.jakobnielsen</groupId>
  <artifactId>java6-gif-backport</artifactId>
  <version>0.2</version>
</dependency>

License

This code is released in the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

You can download a copy of the version here: http://www.gnu.org/licenses/gpl-2.0.txt

References

  • A-Pressen Interaktiv - Uses it for generating online gif images on more that 65 sites - http://www.api.no
  • A large german company that hopefully will allow me to publish their name soon. pliiz! ;)

Resources