【问题标题】:In Rmagic how to add interline spacing on image with caption在 Rmagic 中,如何在带有标题的图像上添加行间距
【发布时间】:2014-08-28 17:19:34
【问题描述】:

使用 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)

如何在此处添加行距?

【问题讨论】:

  • 你解决过这个问题吗?我也有同样的问题。

标签: ruby imagemagick rmagick


【解决方案1】:

它是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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-06
    • 2016-01-12
    • 2022-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-28
    相关资源
    最近更新 更多