Created
December 20, 2013 19:00
-
-
Save jparishy/8059685 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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