使用Rmagic我正在执行以下操作来创建包含大量文本的图像
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
这给出了错误:
undefined method `interline_spacing=' for #<Magick::Image::Info:0x00000101aad190> (NoMethodError)
如何在此处添加行间距?
答案 0 :(得分:2)
它是Draw
对象的属性,而不是Image
对象的属性。它适用于明确的换行符。至少那就是它如何为我工作:
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