保持上传头像比例

exceptionHandle
wanglinchun 12 years ago
parent 0d44c2314c
commit ae7949e8cc

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

Loading…
Cancel
Save