Paperclip/Passenger NotIdentifiedByImageMagickError:

Chr*_*ris 5 ruby-on-rails passenger paperclip

当我尝试在我的本地机器使用PaperclipRuby on Rails上传照片时,它可以很好地工作.

当我尝试使用Paperclip在我们的Linux(CentOS 5.2)服务器上使用Apache和Phusion Passenger在Ruby on Rails上传照片时,我得到:

2 errors prohibited this user from being saved
There were problems with the following fields:
- Avatar /tmp/stream20091026-21120-1qdbnul-0 is not recognized by the 'identify' command.
- Avatar /tmp/stream20091026-21120-1qdbnul-0 is not recognized by the 'identify' command.
Run Code Online (Sandbox Code Playgroud)

我尝试添加:

Paperclip.options[:command_path] = "/usr/local/bin"
Run Code Online (Sandbox Code Playgroud)

到production.rb但它并没有什么区别.

在日志文件中,我收到以下错误:

参数:{"commit"=>"Upload","action"=>"update","_ method"=>"put","authenticity_token"=>"419410afc22737cd2f6b6096a95327db76a48ba9","controller"=>"users","user" "=> {"avatar"=>#}} [paperclip]保存附件.[paperclip]处理时收到错误:

'identify'命令无法识别/ tmp/stream20091026-20752-1g568yk-0.

Vla*_*anu 4

Identify 是ImageMagick包中的一个命令行实用程序。

从其主页:

识别程序描述一个或多个图像文件的格式和特征。它还报告图像是否不完整或损坏。返回的信息包括图像编号、文件名、图像的宽度和高度、图像是否进行颜色映射、图像的颜色数、图像的字节数、图像的格式( JPEG、PNM 等),最后是读取和处理图像所需的秒数。详细选项还提供更多属性。

首先,将映像复制到服务器上并对其运行识别命令。您应该收到类似以下内容:

identify ~/capture.jpg 
capture.jpg JPEG 1216x244 1216x244+0+0 8-bit DirectClass 97.7kb
Run Code Online (Sandbox Code Playgroud)

如果收到错误,请尝试升级服务器上的 ImageMagick 包。您可以在这里找到更新的二进制版本: http://www.imagemagick.org/script/binary-releases.php