How can I analyze a GIF file with Java code to determine whether it is a
single static GIF or an animated GIF?

Signature
Rhino
---
rhino1 AT sympatico DOT ca
"There are two ways of constructing a software design. One way is to make it
so simple that there are obviously no deficiencies. And the other way is to
make it so complicated that there are no obvious deficiencies." - C.A.R.
Hoare
Andrew Thompson - 30 Sep 2005 18:25 GMT
> How can I analyze a GIF file with Java code to determine whether it is a
> single static GIF or an animated GIF?
Marco Schmidt has a list of image libraries at the page here..
<http://schmidt.devlib.org/java/pixel-image-io-libraries.html>
I do not have much experience with them, beyond the
'FM Software - AnimatedGifEncoder' (which worked
just fine) but I notice they also offer a decoder..
Rationem - 30 Sep 2005 22:55 GMT
An animated gif file will have an extra header.
The GIF Header is 12 bytes plus the Color Table (which is num colors *
3)
12bytes + (255 * 3)bytes = 777bytes
After those bytes you can attempt to read one more byte
If it is the byte is....
0x2c The image block has started. There is no animation
0x21 Read the next byte. If the next byte is....
0xff Application Extension (++++ ANIMATED ++++)
0xf9 Graphics Control Block (++++ NOT animated ++++)
Regular GIF (87 + 89): (87 does not have graphics control ext)
[GIF Header]
[Graphics Control]
[Image Block]
[Trailer]
An animated GIF:
[GIF Header]
[Application Control]
[
[Graphics Control]
[Image Block]
]
Rhino - 02 Oct 2005 20:42 GMT
> How can I analyze a GIF file with Java code to determine whether it is a
> single static GIF or an animated GIF?
Thank you both for your suggestions!
Rhino