2017-02-19 23 views
0

將文本添加到圖像我有一個Rails項目4我在升級到Rails 5.圖片上傳符插入文本的時候,當我拿出添加文本(c.draw "text 0,0 'test'"),它的工作原理:Rails的5斷裂通過Carrierwave

Uploader.rb文件:

class LeedUploader < CarrierWave::Uploader::Base 
    # Include RMagick or MiniMagick support: 
    include CarrierWave::RMagick 
    include CarrierWave::MiniMagick 

    storage :fog 

    def store_dir 
    "uploads/#{model.class.to_s.underscore}/#{model.job.JobNo}/#{model.leed_item.Team}/#{model.id}" 
    end 

    def fix_exif_rotation #this is my attempted solution 
     manipulate! do |img| 
      img.tap(&:auto_orient) 
     end 
    end 

    def add_text_medium 
     manipulate! do |img| 
      img.combine_options do |c| 
        c.background '#000' 
       c.gravity 'South' 
       c.fill '#00FF3A' 
       c.pointsize '24' 
       c.draw "text 0,0 'test'" 
      end 
      img 
      end 
    end 

    version :medium do   
     process :resize_to_limit => [400, 400] 
     process :fix_exif_rotation 
     process :add_text_medium 
    end 
end 

回答

0

我從6.8.7-0 ImageMagick的升級到最新版本解決了該問題:7.0.4-10使用BREW。

+0

請注意,brew可能無法在您的生產服務器上使用,因此您應該確保您可以在服務器上安裝新版本的imagemagick,然後再根據此解決方案進行安裝。 –