paperclip accepting jpg and png on production

南楼画角 提交于 2019-12-04 11:30:34

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"

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
tamersalama

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!