I am trying to create an image file from text using Rmagick in ruby. Additionally I need it's background transparent. My code:
canvas = Image.new(400, 60)
watermark_text = Draw.new
watermark_text.annotate(canvas, 0,0,0,0, text) do
self.gravity = WestGravity
self.pointsize = 50
self.font = "whatever.ttf"
self.fill = 'black'
self.stroke = "none"
end
canvas.write(@path)
It works, but the background of the image is white and I need it to be transparent. Any ideas? File is saved as png.
When you create an image, the default background is white. You can tell rmagick
you want a different background:
canvas = Image.new(400, 60) do |c|
c.background_color= "Transparent"
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With