text to images using RMagick

N

Nick Hayworth

Hi all

just wondering if it's possible to convert a string to an image x pixels
wide. The text should automatically wrap at x pixels. i can do this using
ImageMagick's convert utility :

convert -size 200x -font Tahoma -pointsize 20 caption:"My very long caption
which should wrap at 200 pixels" output.gif

I looked at the annotate method in RMagick but it looks like I need to
specify the image dimensions. Can anyone suggest how I might get the effect
I want using RMagick?
 
T

Timothy Hunter

Nick said:
Hi all

just wondering if it's possible to convert a string to an image x pixels
wide. The text should automatically wrap at x pixels. i can do this using
ImageMagick's convert utility :

convert -size 200x -font Tahoma -pointsize 20 caption:"My very long caption
which should wrap at 200 pixels" output.gif

I looked at the annotate method in RMagick but it looks like I need to
specify the image dimensions. Can anyone suggest how I might get the effect
I want using RMagick?

I got this to work but while doing so I discovered that RMagick is
missing an attribute in the Image::Info class. I'll upload a new version
tomorrow and post an announcement here.
 
T

Timothy Hunter

Nick said:
Hi all

just wondering if it's possible to convert a string to an image x pixels
wide. The text should automatically wrap at x pixels. i can do this using
ImageMagick's convert utility :

convert -size 200x -font Tahoma -pointsize 20 caption:"My very long caption
which should wrap at 200 pixels" output.gif

I looked at the annotate method in RMagick but it looks like I need to
specify the image dimensions. Can anyone suggest how I might get the effect
I want using RMagick?
Okay, I just uploaded a new version of RMagick, version 1.8.2. With this
version you can use this script:

require 'RMagick'
include Magick

img = Image.read("caption:My very long caption which should wrap at 200
pixels") do
self.size = "200x"
self.pointsize = 20
self.font = "Tahoma"
end

img[0].display
 
N

Nick Hayworth

Timothy Hunter said:
Okay, I just uploaded a new version of RMagick, version 1.8.2. With this
version you can use this script:

require 'RMagick'
include Magick

img = Image.read("caption:My very long caption which should wrap at 200
pixels") do
self.size = "200x"
self.pointsize = 20
self.font = "Tahoma"
end

img[0].display

that's excellent! Thanks for taking the time to do this and for writing such
a great library.

nick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,736
Latest member
zacharyharris

Latest Threads

Top