Probem with paperclip accepting jpg and png for production

I use the PaperClip plugin in a 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 great in development (Mac OSX + Mongrel). But when I put it into 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 suggest, but that didn't help!

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

Any ideas?

Thanks,

There

+4
source share
3 answers

On a production server, try running:

 which identify 

This should give you the path to ImageMagick to determine the binary - if you do not have ImageMagick installed or it is not in your path.

If it returns something like "/ usr / bin / ident", you need to set the Paperclip parameters in the production.rb environment file so that:

 Paperclip.options[:command_path] = "/usr/bin" 
+5
source

In case anyone 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 am 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 the jpeg coding library from the source, 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 installed ImageMagick from the source again:

 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 download JPG files using 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 
+4
source

I had the same problem after switching to Lion. Running 'ident image.jpg' threw a dyld: Library not loaded error.

This post helped solve the problem.

0
source

All Articles