Posted on 2007-12-07 17:32
Evily.Win 阅读(12)
评论(0) 编辑 收藏 网摘
I go on a lot of Bulletin Board, every has its own limits of size for the avatars, instead of the resize manually I created a script which does it for me with RMagick
#!/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