From: Adriana Mikolaskova Date: 2012-11-06T05:51:21+09:00 Subject: Re: Display Text as Image Hello, your code worked fine for me, just one little problem occured. When there are no linebreaks in the text, all the text is displayed on one line (that means invisible). I found different solutions, just wanted to ask here: is it really necassary to figure out, how many characters a image-with can hold and insert the line-breaks in the text? Or did I miss some easier method for inserting line-breaks at the end of the image-width? Best regards Adriana > > def make_image_with_text(x,y,backg_col,foreg_col,text,font,pointsize) > im=Magick::Image::new(x,y) do > self.background_color=backg_col > end > gc=Magick::Draw::new() > gc.annotate(im,x,y,0,0,text) do > self.font_family=font > self.fill=foreg_col > self.stroke=foreg_col > self.pointsize=pointsize > self.gravity=Magick::CenterGravity > end > im > end > > To have a 2000x1000 black image with "This is a test" written in > 20point Tahoma in red in it you should call the above as follows: > > im=make_image_with_text(2000,1000,'black','red','This is a > test','Tahoma',20) > im.display > > O -- Posted via http://www.ruby-forum.com/.