Using two colours in a text to image conversion

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
mthomsit

Using two colours in a text to image conversion

Post by mthomsit »

Hi,

I am trying to create an image which will be used as the title in a web page. The font is non-standard, hence the need to use an image.

What I would like to be able to do is append a different coloured fullstop on the end of the text string but I don't think it's possible using just one caption. If the title is long the text might wrap over a number of lines so the full stop would have to be positioned on the right line in the right place.

Would anyone be able to offer me some assistance? The current image is generated using rmagick (for ruby) but it should be clear:

Code: Select all

title = "caption:"+self.title
		img = Image.read(title) do
			self.size = "435x"
			self.pointsize = 26
			self.font = "GriffithGothic-Ultra"
			self.fill = "#006bcc"
		end
Thank you for any help you can offer
Mark
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Using two colours in a text to image conversion

Post by fmw42 »

As far as I know, you cannot change color, pointsize, font, etc within ONE instance of caption: or label:

You will need to do it twice and append the results.
mthomsit

Re: Using two colours in a text to image conversion

Post by mthomsit »

Hi, yes that is what I suspected. Does anyone have an example like that which shows attaching text in the right place?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Using two colours in a text to image conversion

Post by fmw42 »

search the archives

read http://www.imagemagick.org/Usage/text/

consider using annotate
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

Re: Using two colours in a text to image conversion

Post by rmagick »

Since you're already using RMagick, you've got RVG. You can use the RVG::Tspan and RVG::Text classes to draw text in different styles. Check out the example at http://studio.imagemagick.org/RMagick/d ... n.html#new.

No automatic line-wrapping, though. :(

You can post questions about RMagick to the RMagick Forum on RubyForge: http://rubyforge.org/forum/?group_id=12 or email me directly at rmagick AT rubyforge DOT org.

Good luck!
Post Reply