ruby - Rmagick - image with transparent background from text -


i trying create image file text using rmagick in ruby. additionally need it's background transparent. code:

canvas = image.new(400, 60)  watermark_text = draw.new watermark_text.annotate(canvas, 0,0,0,0, text)   self.gravity = westgravity   self.pointsize = 50   self.font = "whatever.ttf"   self.fill = 'black'   self.stroke = "none" end  canvas.write(@path) 

it works, background of image white , need transparent. ideas? file saved png.

when create image, default background white. can tell rmagick want different background:

canvas = image.new(400, 60) |c|   c.background_color= "transparent" end 

Comments