头像上传调整
This commit is contained in:
parent
8e52e900d7
commit
6cfd5d6dbd
|
@ -31,6 +31,7 @@ class AvatarController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
size = @temp_file.size
|
||||||
if @temp_file && (@temp_file.size > 0)
|
if @temp_file && (@temp_file.size > 0)
|
||||||
if @temp_file.size > Setting.upload_avatar_max_size.to_i
|
if @temp_file.size > Setting.upload_avatar_max_size.to_i
|
||||||
@status = 1
|
@status = 1
|
||||||
|
@ -81,7 +82,7 @@ class AvatarController < ApplicationController
|
||||||
|
|
||||||
sleep(3)
|
sleep(3)
|
||||||
|
|
||||||
unless File.size(diskfile) > 0
|
unless File.size(diskfile) < size
|
||||||
logger.info("###############################################################sleep")
|
logger.info("###############################################################sleep")
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,20 +35,20 @@ module Trustie
|
||||||
|
|
||||||
def compress(size=300)
|
def compress(size=300)
|
||||||
backup if @bak
|
backup if @bak
|
||||||
begin
|
# begin
|
||||||
f = Magick::ImageList.new(@file)
|
# f = Magick::ImageList.new(@file)
|
||||||
if f.format != 'GIF'
|
# if f.format != 'GIF'
|
||||||
width = size
|
# width = size
|
||||||
if f[0].columns > width
|
# if f[0].columns > width
|
||||||
proportion = (width/f[0].columns.to_f)
|
# proportion = (width/f[0].columns.to_f)
|
||||||
height = (f[0].rows*proportion)
|
# height = (f[0].rows*proportion)
|
||||||
f.resize_to_fill!(width,height.to_i)
|
# f.resize_to_fill!(width,height.to_i)
|
||||||
f.write(@file)
|
# f.write(@file)
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
rescue Exception => e
|
# rescue Exception => e
|
||||||
Rails.logger.error "[Error] compress : ===> #{e}"
|
# Rails.logger.error "[Error] compress : ===> #{e}"
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
def backup
|
def backup
|
||||||
|
|
Loading…
Reference in New Issue