ディレクトリ下の画像の一括回転
90度回転させる
ruby imgrotate.rb ~/tmp/picture/*.png ~/tmp/result/ 90
imgrotate.rb
#!/usr/bin/env ruby require 'rubygems' require 'RMagick' include Magick if ARGV.size < 3 puts 'pathと保存先と角度が必要です' puts ' e.g. ruby imgrotate.rb ~/tmp/picture/*.png ~/tmp/result/ 180' exit(1) end angle = ARGV.pop.to_i # 回転角度 dest = ARGV.pop # 保存先 path = ARGV path.each{|file| destFile = "#{dest}#{file.split(/\//).last}" puts "#{file} => #{destFile}" img = Image.from_blob(File.read(file)).shift img.rotate(angle).write(destFile) fDisabled = GC.enable GC.start GC.disable if fDisabled }