Open Imaging - Development of a free GIF decoder
I finished development of my very own GIF image decoder. It’s freely available on GitHub (see github.com/DhyanB/Open-Imaging) and licensed under the Apache License, Version 2.0.
During the development the following resources have been very helpful to me:
- GIF Specification
- Project: What’s In A GIF - Bit by Byte by Matthew Flickinger Detailed introduction, well written, plain and clear. Uses a tiny sample image to help understanding of what’s going on.
- Decoding GIF Clarifications and notes on some quirks in the specification and prevalent implementations This one also has a list of links to helpful pages and articles.
- About the GIF disposal method
- LZW Revisited by Mark Nelson In-depth article on LZW data compression.
- How animated GIFs work
- Animation Basics by ImageMagick offers some general information and important details on disposal methods.
- Disposal Methods - What do I do with the empties?
Normally the specification and one or two good articles should be sufficient to get started, but there are several ambiguities in the specification that lead to inconsistent understanding and implementation of the standard. Therefore it’s important to look at the problem from a couple of different perspectives. Examples of problematic topics include: background drawing, handling clear codes and implementing disposal methods.
One of the most widley used GIF decoder written in Java is the one from Kevin Weiner (2003). However, like most Java decoders I came across, it has a bug that causes ArrayIndexOutOfBounds
exceptions to be thrown for a certain number of GIF images. Here is a description of the bug. As you can see, this bug affects the famous ImageIO.read()
method that comes with Java itself as well as the Apache Commons imaging library. As far as I know, the only Java library not suffering from this bug is GIF4J. It is, however, quite expensive and closed source.
/images/moon-landing.gif