简体   繁体   中英

Paperclip / Passenger NotIdentifiedByImageMagickError:

When I try to upload a photo in Ruby on Rails using Paperclip on my local machine it works perfectly.

When I try to upload a photo in Ruby on Rails using Paperclip on our Linux ( CentOS 5.2) server with Apache and Phusion Passenger , I get:

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.

I tried adding:

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

to production.rb but it didn't make a difference.

In the log files I get the following errors:

Parameters: {"commit"=>"Upload", "action"=>"update", "_method"=>"put", "authenticity_token"=>"419410afc22737cd2f6b6096a95327db76a48ba9", "controller"=>"users", "user"=>{"avatar"=>#}} [paperclip] Saving attachments. [paperclip] An error was received while processing:

/tmp/stream20091026-20752-1g568yk-0 is not recognized by the 'identify' command.

Identify is a command-line utility inside the ImageMagick package.

From its homepage:

The identify program describes the format and characteristics of one or more image files. It also reports if an image is incomplete or corrupt. The information returned includes the image number, the file name, the width and height of the image, whether the image is colormapped or not, the number of colors in the image, the number of bytes in the image, the format of the image (JPEG, PNM, etc.), and finally the number of seconds it took to read and process the image. Many more attributes are available with the verbose option.

First, copy the image on the server and run the identify command on it. You should receive something like:

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

If you receive an error, try upgrading the ImageMagick package on your server. You may find an updated binary release here: http://www.imagemagick.org/script/binary-releases.php

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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