头像上传调整

This commit is contained in:
cxt 2017-03-17 17:40:26 +08:00
parent 8e52e900d7
commit 6cfd5d6dbd
2 changed files with 16 additions and 15 deletions

View File

@ -31,6 +31,7 @@ class AvatarController < ApplicationController
end
end
size = @temp_file.size
if @temp_file && (@temp_file.size > 0)
if @temp_file.size > Setting.upload_avatar_max_size.to_i
@status = 1
@ -81,7 +82,7 @@ class AvatarController < ApplicationController
sleep(3)
unless File.size(diskfile) > 0
unless File.size(diskfile) < size
logger.info("###############################################################sleep")
sleep(0.5)
end

View File

@ -35,20 +35,20 @@ module Trustie
def compress(size=300)
backup if @bak
begin
f = Magick::ImageList.new(@file)
if f.format != 'GIF'
width = size
if f[0].columns > width
proportion = (width/f[0].columns.to_f)
height = (f[0].rows*proportion)
f.resize_to_fill!(width,height.to_i)
f.write(@file)
end
end
rescue Exception => e
Rails.logger.error "[Error] compress : ===> #{e}"
end
# begin
# f = Magick::ImageList.new(@file)
# if f.format != 'GIF'
# width = size
# if f[0].columns > width
# proportion = (width/f[0].columns.to_f)
# height = (f[0].rows*proportion)
# f.resize_to_fill!(width,height.to_i)
# f.write(@file)
# end
# end
# rescue Exception => e
# Rails.logger.error "[Error] compress : ===> #{e}"
# end
end
def backup