#!/usr/bin/ruby
require "RMagick"
$SIZES = [80 , 100 , 110 , 128]
if !ARGV[0]
puts "Usage: mk_avatars.rb SourceAvatarPath"
exit
end
image = Magick::Image.read(ARGV[0]).first
$SIZES.each do |sz|
puts "Generating Avatar : #{sz}"
out = image.thumbnail(sz,sz)
file = "out_#{sz}.#{image.format}"
out.write(file)
end
文章来源:http://snippets.dzone.com/posts/show/3860