# Transparent text with rmagick?

**URL:** <https://www.ruby-forum.com/t/transparent-text-with-rmagick/83618>\
**Category:** Ruby\
**Created:** [January 27, 2007, 7:13pm UTC](https://www.ruby-forum.com/t/transparent-text-with-rmagick/83618 "2007-01-27T19:13:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 27, 2007, 7:13pm UTC](https://www.ruby-forum.com/t/transparent-text-with-rmagick/83618/1 "2007-01-27T19:13:05Z")

</div>

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:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
+81 (0)80 6521 9559  
skype: callto://d3ntaku

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 27, 2007, 9:37pm UTC](https://www.ruby-forum.com/t/transparent-text-with-rmagick/83618/2 "2007-01-27T21:37:27Z")

</div>

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’}
