Here is the way to do it:
require 'rubygems'
require 'RMagick'
include Magick
image = Image.new(50, 50) {
self.background_color = "white"
}
text = Draw.new
text.annotate(image, 0,0,0,40, 'Named Colors') {
self.fill = 'black'
self.pointsize = 32
}
image.write("image.png")
If you encounter error in mongrel like
Mongrel not starting: `initialize_without_backlog': Cannot assign requested address, it may be because if you use rmagick and the process keeps running as it cannot find the requested font. Then you need to find the process like ruby script/server. look for the process id.
use this command in OSX: ps -ef
look for the line ruby script/server
get the pid (e.g. 925652)
then use this command
kill -9 925652