resize img

This commit is contained in:
wanglinchun 2014-01-16 17:08:44 +08:00
parent ff9bde0b9f
commit 5cacdd906d
3 changed files with 6 additions and 2 deletions

View File

@ -7,6 +7,7 @@ gem "coderay", "~> 1.0.6"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder", "3.0.0"
gem 'acts-as-taggable-on'
gem 'rmagick'
# Optional gem for LDAP authentication
group :ldap do

View File

@ -78,6 +78,7 @@ GEM
rake (10.0.4)
rdoc (3.12.2)
json (~> 1.4)
rmagick (2.13.2)
ruby-openid (2.1.8)
sprockets (2.2.2)
hike (~> 1.2)
@ -108,4 +109,5 @@ DEPENDENCIES
rack-openid
rails (= 3.2.13)
rdoc (>= 2.4.2)
rmagick
ruby-openid (~> 2.1.4)

View File

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