class WritePic
require "RMagick"
require "uuid"
def (pic_data,ori_name,resize = nil,file_type = "jpg",tag=false)
#("c:/programData/ruby-uuid") if RAILS_GEM_VERSION == '2.1.2'
uuid = ori_name || "#{}.#{file_type}"
i = Magick::Image.from_blob(pic_data).first
if resize
p=resize[:width].to_i*1.00 /
!(resize[:width],resize[:height]|| *p)
end
wh=0
width =
height =
if width > height
wh =1
end
("#{RAILS_ROOT}/public/images/user_pic/#{uuid}")
if tag
return wh,uuid
else
return uuid
end
end
def self.get_pic(url)
uuid = "#{}.#{file_type}"
img_orig1 = Magick::(url).first
image1 = img_orig1.resize_to_fit(300,300)
("#{RAILS_ROOT}/public/images/weibo_pic/#{uuid}")
return uuid
end
end