RMagickの使い方のメモ
ライブラリのロード
require 'RMagick'
ファイルの読み込み
img = Magick::ImageList.new(path)
画像のサイズ
img.columns #=> 横幅
img.rows #=> 高さ
画像のサイズを変更する
width = 100 #横幅
height = 80 #高さ
image.resize(width, height)
縦横比を固定して画像のサイズを変更する
width = 100
height = (img.rows.to_f * width.to_f / img.columns.to_f).to_i
img.resize(width, height)
画像を保存する
img.write('/path/to/file')
画像を回転する
amount = 90 #角度(時計回り)
new_img = img.rotate(amount)