Search code examples
ruby-on-railsrubyffmpegrmagickanimated-gif

How to tell if GIF is animated?


I have this Rails app with Paperclip for image uploads -- but how do I check if the image is an animated GIF with RMagick?


Solution

  • 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