secret
Last active

GIF frame randomizer

  • Download Gist
gifrandom.rb
Ruby
1 2 3 4 5 6
#!/usr/bin/env ruby
 
frames=`gifsicle -I #{ARGV[0]}|head -1`.match(/ (\d+) images/)[1].to_i - 1
shuffled=(0..frames).to_a.shuffle.map{|i| "\"##{i}\""}.join(' ')
random=File.basename(ARGV[0],'.gif') + '-random.gif'
`gifsicle --colors=255 #{ARGV[0]} | gifsicle --unoptimize | gifsicle -O3 #{shuffled} > #{random}`

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.