text to images using RMagick

R

Ray

Hi, I used this thread
(http://groups.google.com/group/comp...86ca02c6af/7868ea24e7069eea?#7868ea24e7069eea)
to get text wrapping working, and it's working great.

The problem I can't seem to crack is forcing linefeeds or newline
breaks. How do I do it in a string constructed as a "caption:"? Or is
there another way to create an image with automatically wrapping text
that would support this?

Ta, Ray


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
 
R

Ray

Hi Tim, thanks for your quick response. I'm very new to this, Im on Mac
OSX 10.4.5, how do I check the version of ImageMagick installed?

Also, when I do get it working, can all text formatting (eg: bold,
italic, colours, etc) work with the caption parameter?

Ta, Ray
 
R

Ray

Tim, i just tried this:

Tiger:/opt/local/bin rails$ composite -version
Version: ImageMagick 6.2.4 02/24/06 Q16 http://www.imagemagick.org

So i guess I'm running ImageMagick 6.2.4???

Also, to clarify my question around text formatting, I need to set
formats in line (on particular words), not globally to the caption
parameter. Can it be done?

Cheers and happy St. Patrick's Day, Ray
 
R

rmagick

Ray said:
Tim, i just tried this:

Tiger:/opt/local/bin rails$ composite -version
Version: ImageMagick 6.2.4 02/24/06 Q16 http://www.imagemagick.org

So i guess I'm running ImageMagick 6.2.4???

Yes, that's right.
Also, to clarify my question around text formatting, I need to set
formats in line (on particular words), not globally to the caption
parameter. Can it be done?

No. ImageMagick is an image processing library so its support for text
is limited. If you absolutely have to do this using Ruby+ImageMagick
then you might have more luck with RMagick's RVG class. It'll still be
hard. While RVG does allow you to specify styling on individual words,
it doesn't support embedded newlines so you'll have to do the
positioning yourself. Check out RVG's support for text at
http://www.simplesystems.org/RMagick/doc/rvgtext.html, with particular
attention to tspans:
http://www.simplesystems.org/RMagick/doc/rvgtspan.html

Another approach would be to produce an EPS file, or a PDF (with
PDF::Writer) that contains the formatted text and then convert it to
the destination format with RMagick.
Cheers and happy St. Patrick's Day, Ray

Thanks! You too!
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top