42

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"
JP Silvashy
  • 46,977
  • 48
  • 149
  • 227
  • reinstalling ImageMagick... just to see if that remedies anything. – JP Silvashy Jan 03 '10 at 19:59
  • 1
    This is related to ImageMagick, but could you also include the paperclip statements that you have in your model? The `command_path` option needs to point ot the location where `identify` is installed. From the command line, you can determine this with `which identify`. – Ryan McGeary Jan 03 '10 at 20:11
  • Bleh, you are right Ryan (again), if you want to answer you get a big green checkmark. – JP Silvashy Jan 03 '10 at 20:34

14 Answers14

49

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"
Ryan McGeary
  • 235,892
  • 13
  • 95
  • 104
15

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.

greeness
  • 15,956
  • 5
  • 50
  • 80
Bill Lipa
  • 2,039
  • 1
  • 19
  • 11
6

I was able to resolve this by doing the following:

brew uninstall imagemagick
brew install imagemagick
wisew
  • 2,672
  • 3
  • 23
  • 30
Mark Ross
  • 61
  • 1
  • 1
4

This happened to me when I upgraded OS X to Lion.

Solved it by...

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

Brian Armstrong
  • 19,707
  • 17
  • 115
  • 144
3

I got it working by installing brew, Link

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!

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Philip
  • 6,827
  • 13
  • 75
  • 104
2

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
1

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.

Ninjaxor
  • 876
  • 12
  • 27
1

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.

0x4a6f4672
  • 27,297
  • 17
  • 103
  • 140
1

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.

sunkil
  • 11
  • 1
0

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 :)

Olivier Amblet
  • 723
  • 3
  • 16
0

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...

0

that also happened to me, i tried all the method that are mentioned above. I just change the paperclip version , then everything works fine.

user1611237
  • 123
  • 1
  • 5
  • 14
0

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.

petrocket
  • 1,458
  • 2
  • 14
  • 17
0

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

Ala'a Mohammad
  • 131
  • 2
  • 4