When I upload a photo, my model fails validation, err well even without any validations I'm returned this error:
/tmp/stream20100103-13830-ywmerx-0 is not recognized by the 'identify' command. and
/tmp/stream20100103-13830-ywmerx-0 is not recognized by the 'identify' command.
I'm confident this is not related to ImageMagick because I've removed any image processing from the uploading, also I've tried uploading different mime types, like .txt files and the such.
Additionally, I found something that may work. A blog post claims that putting the following in my environment (in this case development.rb)
Paperclip.options[:command_path] = "/opt/local/bin"
This is related to ImageMagick. The command_path
option needs to point to the location where identify
is installed. From the command line, you can determine this with which identify
.
$ which identify
/some/path/to/identify
Afterwards, set command_path
to that path (in config/environments/development.rb
):
Paperclip.options[:command_path] = "/some/path/to"
This can also be caused by using fairly old versions of Paperclip
(for example, version 2.4.x) with newer, incompatible versions of the Cocaine
gem.
I was able to resolve this by doing the following:
brew uninstall imagemagick
brew install imagemagick
This happened to me when I upgraded OS X to Lion.
Solved it by...
do a
brew list
to see all packages you have and save this somewhereuninstalling homebrew (see 'Uninstallation' on this page https://github.com/mxcl/homebrew/wiki/Installation )
reinstall homebrew with the usual
ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
reinstalling all packages
brew install ghostscript
brew install imagemagick
etc for any others you have
Note, before ghostscript would reinstall I had to apply the suggestion found here: https://github.com/mxcl/homebrew/issues/6381
brew edit ghostscript
Then add the def patches
block to the bottom of the Ghostscript class:
class Ghostscript < Formula
.... existing code here ....
def patches
{ :p0 => 'http://ftp.netbsd.org/pub/NetBSD/packages/pkgsrc/print/ghostscript/patches/patch-ak' }
end
end
The above patch may be merged in by the time you read this.
After that imagemagick detected jpegs correctly again.
TL;DR completely uninstall and reinstall homebrew, ghostscript (with patch for Lion), and imagemagick
I got it working by installing brew, http://mxcl.github.com/homebrew/
And then i typed:
brew install imagemagick
and after that
gem install rmagick
Then I just deleted the option paths (Paperclip.options[:command_path] = "...") that I typed in manually in environment/development.rb and initialize/paperclip.rb
Added rmagick to gem file. Restarted the server and it worked like a charm!
This worked fromhttp://arglebargle.posterous.com/path-environment-variable-for-rails-using-pas
Put something like this in the VirtualHost (or wherever passenger is set up):
SetEnv PATH /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/mysql/bin
To add one more potential solution that I haven't seen discussed much: ldconfig
.
I had the same problem that I just spent a day and a half tracking down. I properly reinstalled ImageMagick from source with the additional png and jpeg support, I added LD_LIBRARY_PATH
and DYLD_LIBRARY_PATH
to the environment variables, I set the :command_path
option for Paperclip in my production environment config. Although the ImageMagick commands worked from the command line, nothing fixed my Paperclip problem.
Finally after seeing ldconfig
mentioned in passing, I tried that on a whim, and it worked.
sudo ldconfig
I may have been able to accomplish the same thing by restarting apache or the hardware, but I wasn't in a position to do that on my own.
You will also get this error message if you try to upload a file that contains colons in it's name as of the latest version.
Usually it helps to specify the path to the identify command with..
Paperclip.options[:command_path] = "/your/path/to/identify"
..as the others mentioned. But the problem can also occur if there is a version mismatch, I recently updated the Ruby-on-Rails Version of an application (to Rails 3.1.10), but forgot to update the paperclip gem. After I updated the paperclip version to 2.8.0 it worked again.
if your are trying to upload a video, then probably, 'identify' tries to delegate the work to ffmpeg. example
identify Desktop/00-ScalingRails-Introduction.mp4 [alaa@Zero>/home/alaa]
identify: delegate failed `"ffmpeg" -v -1 -vframes %S -i "%i" -vcodec pam -an -f rawvideo -y "%u.pam" 2> "%Z"' @ error/delegate.c/InvokeDelegate/1061.
identify: unable to open image `/tmp/magick-XXHF4ImT.pam': @ error/blob.c/OpenBlob/2498
in this example, installing ffmpeg removed the error message from the list of validation errors
Just to say, you can also have this error message for what it means.
In my case the file size was 0 bytes length because I forgot to flush it after writing it from a Zip, and passing this resource to Paperclip.
It might be interesting to check that you can actually open the file with your preferred viewer before reading the other answer from this thread :)
If you're a mac user and this has only been a problem since updating your OS to 10.8 then it could be an X11 issue, as outlined here http://support.apple.com/kb/HT5293
identify ~/path/to/image
Was not working for me even after trying all the above fixes. I installed XQuartz from http://xquartz.macosforge.org/landing/ and now it is working again.
May help others out too...
that also happened to me, i tried all the method that are mentioned above. I just change the paperclip version , then everything works fine.
I had this issue when using OSX + MAMP + Passenger + Paperclip and after setting the command_path and ensuring imagemagick was properly installed via brew, properly setting the temp and upload directories for passenger to something writable, it still wouldn't work!
The solution was to edit the envvars file for MAMP in /Applications/MAMP/Library/bin/envvars and comment out the export DYLD_LIBRARY_PATH line.
That is, change the line that says
export DYLD_LIBRARY_PATH
to
# export DYLD_LIBRARY_PATH
Then restart MAMP and feel the elation when your images are properly uploading/resizing.
来源:https://stackoverflow.com/questions/1996102/rails-paperclip-and-passenger-is-not-recognized-by-the-identify-command