Paperclip / Passenger NotIdentifiedByImageMagickError:

时间:2009-10-26 09:51:09

标签: ruby-on-rails passenger paperclip

当我尝试使用本地计算机上的Ruby on RailsPaperclip上传照片时,效果非常好。

当我尝试使用Paperclip在我们的Linux(CentOS 5.2)服务器上使用Paper和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”=>“上传”,   “action”=>“update”,“_ method”=>“put”,   “authenticity_token”=> “中419410afc22737cd2f6b6096a95327db76a48ba9”,   “控制器”=> “中的用户”,   “用户”=> { “化身”=>#}}   [回形针]保存附件。   [paperclip]收到错误   处理时:

           

/ tmp / stream20091026-20752-1g568yk-0是   不被'识别'认可   命令。

2 个答案:

答案 0 :(得分:4)

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

从其主页:

  

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

首先,复制服务器上的映像并在其上运行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

答案 1 :(得分:0)

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