Forum: Ruby transparent text with rmagick?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3d46d8c82d2167ffef81fac65ec92838?d=identicon&s=25 dc (Guest)
on 2007-01-27 19:13
(Received via mailing list)
hi -

(this maybe more an imagemagick q that a ruby one, but here goes ..)

using rmagick / I have a small script for generating some type, but I
cannot get the type to come out as transparent png - it comes out just
on solid white .

does this have to be done with masks and compositing? there are a
number of methods that look like they should work (transparent_color
etc), but dont seem to...

is the library broken or am i doing something wrong?

tx,

/dc

---------
require 'rubygems'
require "RMagick"
include Magick

outfile = "output/matte.png"

drawObj = Magick::Draw.new
drawObj.font = './fonts/Ghoul.ttf'
drawObj.pointsize=30
drawObj.fill = '#44ff00'

buffer = Magick::Image.new(250,100)
drawObj.text(20,50, "hello world")
drawObj.matte(3,3,PaintMethod::ReplaceMethod)
drawObj.draw(buffer)
buffer.opacity = 1
buffer.transparent_color = '#000000'
buffer.matte = true
buffer.write(outfile)

system("open #{outfile}")



--
-------------------------------------------
      David "DC" Collier
mailto:dc@pikkle.com
      +81 (0)80 6521 9559
      skype: callto://d3ntaku
3afd3e5e05dc9310c89aa5762cc8dd1d?d=identicon&s=25 Timothy Hunter (Guest)
on 2007-01-27 21:37
(Received via mailing list)
dc wrote:
> etc), but dont seem to...
>
> is the library broken or am i doing something wrong?
>
> tx,
>
> /dc
Set the background color to "none" when you create the image:

buffer = Magick::Image.new(250, 250) {self.background_color = 'none'}
This topic is locked and can not be replied to.