Ruby 在Rmagic中,如何在带有标题的图像上添加行间间距
使用Rmagic,我将执行以下操作以创建包含大量文本的图像Ruby 在Rmagic中,如何在带有标题的图像上添加行间间距,ruby,imagemagick,rmagick,Ruby,Imagemagick,Rmagick,使用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::WestGravit
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)
用于#的未定义方法“行间间距=”(NoMethodError)
如何在此处添加线条空间?它是
绘图
对象的属性,而不是图像
对象的属性。它适用于显式换行。至少对我来说是这样的:
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
你解决过这个问题吗?我也有同样的问题。