Skip to content

Instantly share code, notes, and snippets.

@hitode909

hitode909/a.rb Secret

Last active January 1, 2018 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hitode909/8dc2a722b24b0cfefd14a47428c33135 to your computer and use it in GitHub Desktop.
Save hitode909/8dc2a722b24b0cfefd14a47428c33135 to your computer and use it in GitHub Desktop.
書き初め
INPUT_FILE, OUTPUT_FILE = *ARGV
OUTPUT_SIZE = 500
HALF_SIZE = OUTPUT_SIZE / 2
files = []
direction = 0
while direction < 45
key_file = "direction-#{direction}.gif"
files.push key_file
system "convert #{INPUT_FILE} -set option:distort:viewport #{OUTPUT_SIZE}x#{OUTPUT_SIZE}-#{HALF_SIZE}-#{HALF_SIZE} -virtual-pixel tile -distort Arc '45 #{direction} 50' +repage #{key_file}"
direction += 9
end
system "convert -coalesce -background white -alpha remove Background -background white -loop 0 -delay 3 #{files.join(' ')} #{OUTPUT_FILE}"
files.each{|file|
File.unlink(file)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment