画像を一括でリサイズします。リサイズした画像はthums/フォルダ以下に格納されます。chmod +x
してパスの通った場所におくと便利です。
使い方
$ resize 50% a.png b.png
convert -resize 50% a.png ./thums/a.png
convert -resize 50% b.png ./thums/b.png
$ resize 320x480 a.jpg b.jpg
ソースコード
#!/usr/bin/env ruby
# Resize images using the ImageMagick
#
# $ resize 50% a.png b.png
# convert -resize 50% a.png ./thums/a.png
# convert -resize 50% b.png ./thums/b.png
require 'fileutils'
require 'rake'
size = ARGV.shift
ARGV.each do |path|
dst_dir = "#{File.dirname(path)}/thums"
FileUtils.mkdir_p dst_dir
dst = "#{dst_dir}/#{File.basename(path)}"
sh "convert -resize #{size} #{path} #{dst}"
end