Retrieving Thumbnail from an Animated Gif – CarrierWave

Hey everyone,

I’ve been mucking around with CarrierWave today and ran into a bit of an issue. When creating a thumbnail from an animated gif the thumbnail was also animated. Unfortunately this led to some of my image-heavy pages hanging for a bit.

This StackOverflow post offers the following solution:

  1.  
  2. #Add this method in your uploader
  3. def remove_animation
  4.   manipulate! do |img, index|
  5.     index == 0 ? img : nil
  6.   end
  7. end
  8.  
  9.  
  10. #Adjust your thumbnail process so that it now includes a call to the new function
  11. version :thumb do
  12.   process :remove_animation
  13.   process :resize_to_limit => [75, 75]
  14.   process :convert => 'jpg'
  15. end

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.