Skip to content

Instantly share code, notes, and snippets.

@dayvsonlima
Forked from hitode909/reverse_animation_gif.rb
Last active August 29, 2015 14:22
Show Gist options
  • Save dayvsonlima/eed804eeb1da97c05514 to your computer and use it in GitHub Desktop.
Save dayvsonlima/eed804eeb1da97c05514 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
require 'rubygems'
require 'RMagick'
filename = ARGV.first
unless filename
warn "usage: #{$0} <ANIMATION GIF FILE>"
exit 1
end
source = Magick::ImageList.new(filename)
dest = Magick::ImageList.new
source.coalesce.reverse.each{ |frame|
dest.push frame
}
dest.delay = source.delay
dest.iterations = 0
dest.optimize_layers(Magick::OptimizeTransLayer).deconstruct.write("out.gif")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment