Thursday, January 15, 2009

Resizing animated gif on attachment_fu's Rmagick

So your animated GIF doesn't animate after going through attachment_fu's Rmagick resizing?

Go find the file lib/technoweenie/attachment_fu/processors/rmagick_processor.rb inside plugins/attachment_fu.

Then find this part:

def with_image(file, &block)
...
binary_data = file.is_a?(Magick::Image) ? file : Magick::Image.read(file).first unless !Object.const_defined?(:Magick)
...
end


and change Magick::Image.read(file) to Magick::ImageList.read(file). The result is:

def with_image(file, &block)
...
binary_data = file.is_a?(Magick::Image) ? file : Magick::ImageList.read(file).first unless !Object.const_defined?(:Magick)
...
end

1 comments:

dave said...

Thank you so much!

This is exactly what I needed and my gifs will no longer be extremely ugly ;)