Jump to content

Determining if a GIF is animated?


Recommended Posts

I have a very large collection of GIF images. My goal is to weed out only those images which are animated.

Does anyone have an idea of how (or if) this might be accomplished?

The only lead I've found is another post referencing the GIF89.DLL file - while I have a copy of the DLL, I've been unable to find any documentation on the methods/properties that can be accessed with this DLL. I'm hoping there is some 'tag' of sorts in GIF files that indicate if it's animated, or has more than one frame, but without being able to access the GIF's properties I'm SOL.

Any pointers would be appreciated!

Link to comment
Share on other sites

get the pixel color at 2,2 of the picture, 4,4,6,6 etc making a \

then compare to themselves? not sure fire but should work almost always

If I understand correctly you mean I should do this with the image showing on screen. I don't think that would work. I have a ton of files on my machine. To do what you are referring to would have to diplay each image and then check pixels at intervals, which isn't even a guaranteed way to determine if it's animated or not. (Not to mention that to display an animated GIF in AutoIt is not easy, you'd have to build a web browser element because regular AutoIt GUI doesn't support animated GIFs from what I'm reading.)

Link to comment
Share on other sites

Well, I figured out a solution. For the benefit of anyone who needs a similar solution in the future, here's what I've got.

Using ImageMagick (for Windows, but it's available for all platforms, and it's free) - you can use the 'identify.exe' program to get info on the GIF. There's no "animation" flag, but when you attempt to get information from an animated gif, it returns multiple instances of data for each frame of the animation, so it's pretty easy to identify a static GIF from a multiple-framed animated GIF.

ImageMagick is a 6 meg download, but the exe you need (and runs standalone) is only 196k.

So, if I run 'identify static.gif', I'm returned the following info:

C:\TEMP>identify static.gif
static.gif GIF 88x31 88x31+0+0 PseudoClass 128c 2196

If I run identify on an animated gif, I get:

C:\TEMP>identify anim.gif
anim.gif[0] GIF 84x57 84x57+0+0 PseudoClass 256c 21.1kb 0.030u 0:01
anim.gif[1] GIF 84x57 84x57+0+0 PseudoClass 256c 21.1kb 0.020u 0:01
anim.gif[2] GIF 84x57 84x57+0+0 PseudoClass 256c 21.1kb 0.020u 0:01
anim.gif[3] GIF 84x57 84x57+0+0 PseudoClass 256c 21.1kb 0.020u 0:01
anim.gif[4] GIF 84x57 84x57+0+0 PseudoClass 256c 21.1kb 0.020u 0:01
anim.gif[5] GIF 84x57 84x57+0+0 PseudoClass 256c 21.1kb 0.010u 0:01
anim.gif[6] GIF 84x57 84x57+0+0 PseudoClass 256c 21.1kb
anim.gif[7] GIF 84x57 84x57+0+0 PseudoClass 256c 21.1kb

By directing the output to a text file, I can then use AutoIt to compare the lines, if it finds multiple lines then it has multiple frames and thus is animated.

Voila!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...