Joel Verhagen Joel Verhagen - 1 year ago 123
PHP Question

How do I programmatically check whether a GIF image is animated?

Here is a link to another question I asked concerning the same project I am working on. I think that bit of background will be helpful.

For those that are too lazy to open a new tab to that question, I'll summarize what I'm trying to do here: I've downloaded about 250,000 images from 4scrape and I want to go through the GIFs and find which ones are animated or not. I need to do this programmatically, because I really don't feel my soul (or my relationship with my girlfriend) could use looking at a couple thousand GIFs from 4chan to see if they are animated or not. If you know the nature of 4chan, then you know the nature of the images (i.e. "tits or GTFO").

I know PHP and Python, but would be willing to explore other solutions. A stand-alone piece of software that works on Windows would also work.

Thanks a lot!

Answer Source

With Python and PIL:

from PIL import Image
gif ='path.gif')
except EOFError:
    isanimated = False
    isanimated = True
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download