开发者

Ruby on rails - Paperclip : Error with png files in production mode

Why do I have this error when I try to upload 开发者_开发知识库a png files in production mode? It works fine with jpg and gif files...

[paperclip] An error was received while processing: #Paperclip::NotIdentifiedByImageMagickError: /tmp/s3,8354,0.png is not recognized by the 'identify' command.>


You can get this problem with a version of ImageMagick with PNG (and anything else) compiled in.

In my setup I'm on MacOSX with a binary download of ImageMagick in /usr/local/ImageMagick-6.6.1/bin and I'm running Rails under Apache/Passenger. I've got Paperclip installed as a plugin.

There are 3 steps needed to get this working:

1: Make sure you have ImageMagick working at the UNIX command line level. This involves adding it to your path and exporting these environment variables (pointing to your ImageMagick installation, of course)

MAGICK_HOME=/usr/local/ImageMagick-6.6.1
DYLD_LIBRARY_PATH=/usr/local/ImageMagick-6.6.1/lib

Check that identify works with your images at the command line level.

2: Tell Paperclip where to find the ImageMagick executables In config/environment.rb add this at the bottom of the file

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

At this point, after restarting Passenger, you would see that 'identify' is run from within Paperclip but is not able to identify the file... the final step is...

3: Identify needs those two exported environment variables - and Apache/Passenger (or other web servers probably) does not pass those through by default! In your passenger vhost file add these lines:

  SetEnv MAGICK_HOME /usr/local/ImageMagick-6.6.1
  SetEnv DYLD_LIBRARY_PATH /usr/local/ImageMagick-6.6.1/lib

Restart apache/passenger and it should work

Good Luck!


This belongs on serverfault imo.

Your ImageMagick is not compiled with PNG support. See this article. I'm sure there are countless more on Google.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜