Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Rmagic how to add interline spacing on image with caption

Using Rmagic I am doing the following to create an image with a large amount of text

message="A very long auto wrapping sentence goes here"
  text_image = Image.read("caption:#{message}") do
  self.size="500x500"
  self.fill="white"
  self.background_color="#67c6ae"
  self.gravity=GravityType::WestGravity
  self.interline_spacing=5
end

This gives the error:

 undefined method `interline_spacing=' for #<Magick::Image::Info:0x00000101aad190> (NoMethodError)

How can I add line space here?

like image 951
user566245 Avatar asked Oct 21 '22 02:10

user566245


1 Answers

It is a property of the Draw object, not the Image object. And it works with explicit line breaks. At least thats how its working for me:

image = Image.new(499,649)
message = "this\nmessage\nis\nmultiline"
draw = Draw.new
draw.annotate(image, 0,0,0,0,message) do
  self.gravity = NorthWestGravity
  self.pointsize = 32
  self.font_family = "Arial"
  self.font_weight = NormalWeight
  self.stroke = "none"
  self.fill = font_color
  self.interline_spacing = -5
end
like image 140
Gal Avatar answered Oct 27 '22 16:10

Gal