Text overlay using RMagick

Text overlay example

For what I’m doing (simple text overlay on an image) this is the setup I’m using. This is based on an article I saw using something to autogenerate images for rails.

require 'RMagick'

image = Magick::Image.read("input").first.minify

drawable = Magick::Draw.new

drawable.pointsize = 18.0
drawable.gravity = Magick::SouthEastGravity
drawable.font_weight = Magick::BoldWeight

tm = drawable.get_type_metrics(image, "numericalruby.com")

drawable.fill = 'red'

drawable.annotate(image,0,0,20,20,"numericalruby.com") {self.fill='black'}


Some good info also available on the RMagick site


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: