如何以编程方式检查GIF图像是否已设置动画? [英] How do I programmatically check whether a GIF image is animated?

查看:161
本文介绍了如何以编程方式检查GIF图像是否已设置动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下链接指向另一个问题我问过我正在研究的同一个项目。我认为这一点背景会有所帮助。

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.

对于那些懒得打开这个问题的新标签的人,我会总结一下我在这里要做的事情:我已经下载了大约250,000张图片来自4scrape,我想通过GIF找到哪些是动画的。我需要以编程方式执行此操作,因为我真的不觉得我的灵魂(或我与我的女朋友的关系)可以使用从4chan查看几千个GIF来查看它们是否有动画。如果您知道4chan的性质,那么您就知道图像的本质(即山雀或GTFO)。

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").

我知道PHP和Python,但愿意探索其他解决方案。在Windows上运行的独立软件也可以使用。

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.

非常感谢!

推荐答案

使用Python和 PIL

from PIL import Image
gif = Image.open('path.gif')
try:
    gif.seek(1)
except EOFError:
    isanimated = False
else:
    isanimated = True

这篇关于如何以编程方式检查GIF图像是否已设置动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆