Skip to content

Instantly share code, notes, and snippets.

@thiagopnts
Last active December 17, 2015 12:29
Show Gist options
  • Save thiagopnts/5610141 to your computer and use it in GitHub Desktop.
Save thiagopnts/5610141 to your computer and use it in GitHub Desktop.
Creates a gif based on images.
require 'optparse'
require 'rmagick'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: gify image1.jpg image2.jpg"
opts.on("-v", "--verbose", "Run verbosely") do |v|
options[:verbose] = v
end
opts.on('-d', '--directory', "Turn the images from a directory into a gif.") do |d|
options[:directory] = d
end
end.parse!
if !options[:directory]
return if ARGV.size == 0
anim = Magick::ImageList.new(*ARGV)
anim.delay = 20
anim.each {|img| img.resize!(200, 200); img.rotate!(180)}
anim.write('awesome.gif')
else
anim = Magick::ImageList.new(*Dir.glob(ARGV.first + '*.JPG'))
anim.delay = 20
anim.each{|img| img.resize!(200, 200); img.rotate!(180)}
anim.write('awesome.gif')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment