Paperclip / Passenger NotIdentifiedByImageMagickError:

当我尝试在我的本地机器上使用Paperclip在Ruby 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. 

我尝试添加:

 Paperclip.options[:command_path] = "/usr/local/bin" 

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

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

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

‘identify’命令无法识别/ tmp / stream20091026-20752-1g568yk-0。

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

从它的主页:

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

首先,复制服务器上的映像并在其上运行identify命令。 你应该得到类似的东西:

 identify ~/capture.jpg capture.jpg JPEG 1216x244 1216x244+0+0 8-bit DirectClass 97.7kb 

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

在我的情况下同样的错误,重新安装imagemagic帮助了(ubuntu 12.10)