ruby --Paperclip::NotIdentifiedByImageMagickError

首先,若是遇到這個問題,Paperclip::NotIdentifiedByImageMagickError,先檢查下環境變量是否配置了ImagicMagick的路徑。html

cmd下path 查看,首先加入ImageMagick path環境git

其次,cmd下運行下面兩個命令:github

convert logo: logo.gif
identify logo.gif

看是否運行成功

若是還沒等到解決ruby

 has_attached_file :photo,
                   :whiny => false, #加入這個配置,看下是否能等到解決
                   :styles => { :medium => "300x300>", :thumb => "100x100>" }

能夠參考https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip.rb這個連接。less

若是問題仍是出現的話,在config/initializers目錄下增長個文件paperclip.rbide

Paperclip.options[:command_path] = "E:\ImageMagick"
Paperclip.options[:swallow_stderr] = false

def run cmd, params = "", expected_outcodes = 0
  command = %Q<#{%Q[#{path_for_command(cmd)} #{params}].gsub(/\s+/, " ")}>
  command = "#{command} 2>#{bit_bucket}" if Paperclip.options[:swallow_stderr]
  output = `#{command}`
  unless [expected_outcodes].flatten.include?($?.exitstatus)
    raise PaperclipCommandLineError, "Error while running #{cmd}"
  end
  output
end

  

特別感謝:https://www.cnblogs.com/lmei/p/3321981.html  以及博主code

相關文章
相關標籤/搜索