如何判断GIF是否动画? [英] How to tell if GIF is animated?

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

问题描述

解决方案

我有这个Rails应用程序与Paperclip进行图像上传 - 但是如何检查图像是否是RMagick的动画GIF? div>

您可以计算与图像相关联的场景。在 Rmagick 中,这意味着这样做:

  image = Magick: :ImageList.new(image_file)

如果image.scene == 0
#this不是一个动画gif
else
#this是一个动画GIF
end


I have this Rails app with Paperclip for image uploads -- but how do I check if the image is an animated GIF with 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屋!

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