Skip to content

Instantly share code, notes, and snippets.

@sc-mobile-ci
Created May 28, 2014 11:35
Show Gist options
  • Save sc-mobile-ci/5041b82b19aac56f85a8 to your computer and use it in GitHub Desktop.
Save sc-mobile-ci/5041b82b19aac56f85a8 to your computer and use it in GitHub Desktop.
Gif
require 'RMagick'
module WGif
class GifMaker
def make_gif(frames_dir, filename, dimensions)
image = Magick::ImageList.new(*frames_dir)
resize(image, dimensions)
image.coalesce
image.optimize_layers Magick::OptimizeLayer
image.write(filename)
end
def resize(image, dimensions)
image.each do |frame|
frame.change_geometry(dimensions) do |cols, rows, img|
img.resize!(cols, rows)
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment