将上传的头像压缩至50x50大小。请确保运行环境RMagick可用。

This commit is contained in:
wanglinchun 2013-08-12 22:46:00 +08:00
parent 9abdd44b63
commit 81eca9f238
1 changed files with 7 additions and 0 deletions

View File

@ -53,6 +53,13 @@ class AvatarController < ApplicationController
# @avatar.source_id = User.current.id
# @avatar.image_file = params[:filename].presence || Redmine::Utils.random_hex(16)
# saved = @avatar.save
begin
f= Magick::ImageList.new(diskfile)
f.scale!(50,50)
f.write(diskfile)
rescue
end
respond_to do |format|
format.js