如何判断GIF是否动画? [英] How to tell if GIF is animated?
本文介绍了如何判断GIF是否动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个带有 Paperclip 的 Rails 应用程序,用于上传图像——但是我如何使用 RMagick 检查图像是否是动画 GIF?
I have this Rails app with Paperclip for image uploads -- but how do I check if the image is an animated GIF with RMagick?
推荐答案
您可以计算与图像关联的 scenes
.在 Rmagick
中,这意味着做这样的事情:
You can count the scenes
associated with the image. In Rmagick
that means doing something like this:
image = Magick::ImageList.new(image_file)
if image.scene == 0
#this is not an animated gif
else
#this is an animated gif
end
这篇关于如何判断GIF是否动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文