0

我正在尝试通过carrierwave和mini_magic将文本放在图像上。代码运行没有错误,但生成的图像上没有文字。

version :text do
   process :put_text_stamp
end

def put_text_stamp
  manipulate! do |img|
    img.combine_options do |c|
      c.gravity 'Center'
      c.fill 'red'
      c.pointsize '22'
      c.draw "text 0,0 'TEXT'"
    end
    img = yield(img) if block_given?
    img
  end
end
4

1 回答 1

2

嗨,就在今天早上,我遇到了同样的问题,我还在 rails 3.2 上,但这个对我来说效果很好。我猜它与你的产量函数有关。

  process :resize_to_limit => [800, 800]
  process :add_text

  def add_text
    manipulate! do |image|
      image.combine_options do |c|
        c.gravity 'Center'
        c.pointsize '22'
        c.draw "text 0,0 'test'"
        c.fill 'white'
      end
      image
    end    
  end
于 2014-01-05T10:44:12.150 回答