简体   繁体   English

Paperclip在Windows上无法使用ImageMagick

[英]Paperclip not working with ImageMagick on Windows

I just downloaded the RJCrop from github featuring use of Paperclip with JCrop. 我刚从github下载了RJCrop,其中使用了Paperclip和JCrop。 I tried running it on my Linux VPS, which worked just fine, however when I run the same project on my development Windows Vista x64 machine, I get this exception. 我尝试在我的Linux VPS上运行它,它运行得很好,但是当我在我的开发Windows Vista x64机器上运行相同的项目时,我得到了这个例外。

[paperclip] identify -format %wx%h 
'C:/Users/darth/AppData/Local/Temp/stream,3420,0.png[0]'

[paperclip] An error was received while processing: 
#<Paperclip::NotIdentifiedByImageMagickError: 
C:/Users/darth/AppData/Local/Temp/stream,3420,0.png 
is not recognized by the 'identify' command.>

[paperclip] identify -format %wx%h 
'C:/Users/darth/AppData/Local/Temp/stream,3420,0.png[0]'

[paperclip] An error was received while processing: 
#<Paperclip::NotIdentifiedByImageMagickError: 
C:/Users/darth/AppData/Local/Temp/stream,3420,0.png 
is not recognized by the 'identify' command.>

Identify is in my PATH 识别是在我的PATH中

C:\>identify -versrubion
Version: ImageMagick 6.6.5-9 2010-11-15 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

And I also added the 我还补充说

Paperclip.options[:command_path] = File.join("c:", "ImageMagick")

configuration to environments/development.rb , but it didn't help. 配置到environments/development.rb ,但它没有帮助。 I'm running Ruby 1.9.2p0 . 我正在运行Ruby 1.9.2p0

I found the issue. 我发现了这个问题。

def shell_quote(string)
  return "" if string.nil? or string.blank?
  if self.class.unix?
    string.split("'").map{|m| "'#{m}'" }.join("\\'")
  else
    %{"#{string}"}
  end
end

The unix? unix? method is defined as 方法定义为

def self.unix?
  File.exist?("/dev/null")
end

which however with Cygwin installed returns true, even when ran in regular cmd (at least for me). 然而,安装Cygwin然后返回true,即使在常规cmd中运行(至少对我而言)。 So I just rewrote it to return false and it works fine. 所以我只是重写它以返回false并且它工作正常。 I also submitted this issue to paperclip on github 我还将此问题提交给github上的paperclip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM