def draw_image(user_name)
img = Magick::Image.new(96, 96){self.background_color = 'white'}
name = user_name.split(" ")
name = name[0][0] + name[-1][0]
txt = Draw.new
# img.annotate(img, width, height, x, y, text)
img.annotate(txt, 0, 0, 0, 35, name){
txt.gravity = Magick::SouthGravity
txt.pointsize = 26
txt.fill = '#3D3D3D'
txt.font_weight = Magick::BoldWeight
}
img.format = 'jpeg'
send_data img.to_blob, :stream => 'false', :filename => 'avatar-default.jpg', :type => 'image/jpeg', :disposition => 'inline'
end
def create
user_name = _user_params[:name]
draw_image(user_name)
if _user_params[:avatar].to_s.empty?
_user_params[:avatar] = draw_image(user_name)
end
user = User.create!(_user_params)
render json: {status: user}, root: false
end
to_blob
, this returns a huge blob string, that somehow errors out while trying to pass it as an argument to a sidekiq worker. Im getting Encoding::UndefinedConversionError: "\x89" from ASCII-8BIT to UTF-8
t = Tempfile.new('pdf.page.image').write(blob)
and i get the same error