2016-07-30 66 views
0

我嘗試將水印應用於我的回形針,它保留顯示錯誤消息並且無法更新/上傳圖像。它保留節目**Rails回形針水印「未初始化的常規回形針」

未初始化的常數回形針::水印:: PaperclipCommandLineError

**

寶石文件

寶石 「回形針」, '4.2' 寶石「 '4.2.6'寶石 '回形針壓縮'

paperclip_processors/watermark.rb

module Paperclip 
    class Watermark < Thumbnail 
    def initialize(file, options = {}, attachment = nil) 
     super 
     @watermark_path = options[:watermark_path] 
     @position  = options[:position].nil? ? "SouthEast" : options[:position] 
    end 

    def make 
     src = @file 
     dst = Tempfile.new([@basename].compact.join(".")) 
     dst.binmode 

     return super unless @watermark_path 

     params = "-gravity #{@position} #{transformation_command.join(" ")} #{@watermark_path} :source :dest" 

     begin 
     success = Paperclip.run("composite", params, :source => "#{File.expand_path(src.path)}[0]", :dest => File.expand_path(dst.path)) 
     rescue PaperclipCommandLineError 
     raise PaperclipError, "There was an error processing the watermark for #{@basename}" if @whiny 
     end 

     dst 
    end 
    end 
end 

lisitng.rb

class Listing < ActiveRecord::Base 
    require 'paperclip_processors/watermark' 
    has_attached_file :image, 
        :processors => [:watermark], 
        :styles => { 
         :medium => { 
         :geometry  => "300x300>", 
         :watermark_path => "#{Rails.root}/public/images/watermark.png" 
         }, 
         :thumb => "100x100>", 
        } 

回答