保持上传头像比例

exceptionHandle
wanglinchun 12 years ago
parent 0d44c2314c
commit ae7949e8cc

@ -55,9 +55,11 @@ class AvatarController < ApplicationController
# saved = @avatar.save
begin
f = Magick::ImageList.new(diskfile)
proportion = (200.0/f[0].columns)
f.resize_to_fill!(200,200)
#f.scale!(50,50)
width = 300.0;
proportion = (width/f[0].columns)
height = (f[0].rows*proportion)
f.resize_to_fill!(width,height)
# f.scale!(width,height)
f.write(diskfile)
rescue Exception => e
logger.error "[Error] avatar : avatar_controller#upload ===> #{e}"

Loading…
Cancel
Save