4

I'm using PaperClip plugin in my Rails application as follows:

  has_attached_file :photo, :styles => {:small => '64X64>', :medium => '250X250>'},
                                      :url  => "/assets/user_photos/:id/:style/:basename.:extension",
                                      :path => ":rails_root/public/assets/user_photos/:id/:style/:basename.:extension"
#  validates_attachment_presence :photo
  validates_attachment_content_type :photo, :content_type => ['image/jpeg', 'image/png','image/gif']
  validates_attachment_size :photo, :less_than => 1.megabytes

It works fine on development(Mac OSX + Mongrel). But when I put it in production (Linux Debian + Apache/Passenger) it only accepts .gif and I get the following error for .png and .jpg:

 Photo /tmp/stream20091028-20066-1t1a0oz-0 is not recognized by the 'identify' command.
 Photo /tmp/stream20091028-20066-1t1a0oz-0 is not recognized by the 'identify' command.

I tried adding the following line as some tutorials suggests but it didn't help!

Paperclip.options[:command_path] = "/usr/local/bin"
Cœur
  • 37,241
  • 25
  • 195
  • 267
Tam
  • 11,872
  • 19
  • 69
  • 119
  • 1
    I havent seen this exact error before but have had *similar* issues when imagemagick/ rmagick have not been compiled correctly. From memory i had to recompile and make sure they were compiled with Gzip/libjpeg/libtiff support – ADAM Oct 28 '09 at 08:44

3 Answers3

5

On your production server, try running:

which identify

This should give you your path to ImageMagick's identify binary -- if it doesn't you don't have ImageMagick installed or it is not in your path.

If it returns something like "/usr/bin/identify", then you'll want to set the Paperclip options in your production.rb environment file to:

Paperclip.options[:command_path] = "/usr/bin"
bensie
  • 5,373
  • 1
  • 31
  • 34
  • Thanks Bensie. It actually gave: /usr/local/bin/identify – Tam Oct 28 '09 at 15:34
  • Then you likely don't have the necessary libs installed. ImageMagick can be a beast, particularly when installing from source. If possible, use the package manager of your OS to install it -- I've had much more success with that. What distro are you using? – bensie Oct 28 '09 at 19:23
  • I'm using Linux Debian on my server..I remember installing it long time ago and it worked in my previous Ruby 1.8.6/Rails 2.3.2 project but I wansn't using paper clip. Now I'm using Ruby 1.9 Rails 2.3.4. You think that makes a difference? – Tam Oct 29 '09 at 03:58
4

In case someone else runs into this problem, I had the same error on my Mac OSX Snow Leopard when processing JPG files (GIF files worked fine though). I'm running Rails 3.0.5 and Paperclip 2.3.11.

[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /var/folders/9D/9DvX1hqSFr04U3drvD9o0U+++TI/-Tmp-/stream20110420-50661-l9je0z.jpg is not recognized by the 'identify' command.

I fixed the problem by installing from source the jpeg encoding library available at http://www.ijg.org/files/jpegsrc.v8c.tar.gz.

cd /usr/local/src
tar xvfz jpeg-8c.tar.gz
cd jpeg-8c
export MACOSX_DEPLOYMENT_TARGET=10.6
./configure --enable-shared --prefix=$CONFIGURE_PREFIX
make
sudo make install

Then I re-installed ImageMagick from source:

cd /usr/local/src
tar xvfz ImageMagick-6.6.9-5.tar.gz
cd ImageMagick-6.6.9-5
export CPPFLAGS=-I/usr/local/include
export LDFLAGS=-L/usr/local/lib
./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --disable-openmp
make
sudo make install

After that I was able to successfully upload JPG files with Paperclip.

[paperclip] convert '/var/folders/9D/9DvX1hqSFr04U3drvD9o0U+++TI/-Tmp-/stream20110420-86578-3ntsgn.jpg[0]' -resize "100x100>" '/var/folders/9D/9DvX1hqSFr04U3drvD9o0U+++TI/-Tmp-/stream20110420-86578-3ntsgn20110420-86578-iiszw5' 2>/dev/null
...
[paperclip] saving /Users/xxx/myrailsapp/public/system/images/5/original/IMG_0001.jpg
mbreining
  • 7,739
  • 2
  • 33
  • 35
0

I had the same issue after upgrading to Lion. Running 'identify image.jpg' threw dyld: Library not loaded error.

This post helped resolving the issue.

Community
  • 1
  • 1
tamersalama
  • 4,093
  • 1
  • 32
  • 35