Skip to content

Instantly share code, notes, and snippets.

@jparishy
Created December 20, 2013 19:00
Show Gist options
  • Save jparishy/8059685 to your computer and use it in GitHub Desktop.
Save jparishy/8059685 to your computer and use it in GitHub Desktop.
require 'sinatra'
require 'RMagick'
def delay(fps)
(100.0 / fps)
end
post '/gifify' do
content_type "image/gif"
temp_files = params.values.map { |value| value[:tempfile] }
filenames = temp_files.map { |file| file.path }
puts filenames
animation = Magick::ImageList.new
filenames.each do |filename|
converted = Magick::Image.read filename
animation.from_blob converted[0].to_blob { |attributes| attributes.format = 'GIF' }
end
animation.delay = delay(24)
animation.iterations = 0
animation.to_blob
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment