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

相关文章:

  • 2021-11-05
  • 2021-11-14
  • 2022-12-23
  • 2021-11-27
  • 2021-09-24
  • 2022-01-20
  • 2022-02-25
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-30
  • 2022-12-23
  • 2021-11-02
  • 2021-08-18
  • 2022-12-23
相关资源
相似解决方案