Identifying Animated GIFs

R

Rhino

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

--
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
 
R

Rationem

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]
]
 
R

Rhino

Rhino said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Animated GIF Viewer 1
InetAddress question 1
Jar: protocol question 22
Basic I/O Question 6
I18N Question re presenting time remaining 2
Design of File Choosers 4
Error Handling Question 3
TreeSet size() Problem 2

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top