From ae7949e8cc0a13402d14d2aea27447e083fffd32 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Mon, 20 Jan 2014 08:18:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E6=8C=81=E4=B8=8A=E4=BC=A0=E5=A4=B4?= =?UTF-8?q?=E5=83=8F=E6=AF=94=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/avatar_controller.rb | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/app/controllers/avatar_controller.rb b/app/controllers/avatar_controller.rb index f691cafb5..3b43fec9c 100644 --- a/app/controllers/avatar_controller.rb +++ b/app/controllers/avatar_controller.rb @@ -49,19 +49,21 @@ class AvatarController < ApplicationController # self.digest = md5.hexdigest end @temp_file = nil - # @avatar = Avatar.new(:receive_file => request.raw_post) - # @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) - proportion = (200.0/f[0].columns) - f.resize_to_fill!(200,200) - #f.scale!(50,50) - f.write(diskfile) - rescue Exception => e - logger.error "[Error] avatar : avatar_controller#upload ===> #{e}" - end + # @avatar = Avatar.new(:receive_file => request.raw_post) + # @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) + 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}" + end respond_to do |format|