我正在尝试在Rails项目中使用Paperclip gem,所以按照文档的说明首先使用Homebrew recipe安装了Imagemagick。
我在模型中添加了我的附件。
has_attached_file :screenshot
这个工作正常,文件上传功能按预期运行。
然后我想要添加缩略图,所以再次按照文档的指示添加到模型中。
has_attached_file :screenshot,
:styles => { :medium => "300x300>",
:thumb => "100x100>" }
此时上传不再起作用。
我查看了开发日志,发现如下内容:
[32mCommand[0m :: identify -format %wx%h '/var/folders/ky/r5gsdhbn6yggbglsg727cc900000gn/T/stream20120302-60051-eh17n7.png[0]'
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError:
/var/folders/ky/r5gsdhbn6yggbglsg727cc900000gn/T/stream20120302-60051-eh17n7.png is not recognized by the 'identify' command.>
在查找一些资料后,我认为问题可能是将默认路径设置为环境变量的问题。
Paperclip.options[:command_path] = "/usr/local/bin/"
但我使用以下方法检查了它的正确性:
which identify
它返回了这个路径
/usr/local/bin/identify
如预期
然后我尝试在命令行中运行identify作为测试,并得到了以下错误
dyld: Library not loaded: /usr/X11/lib/libfreetype.6.dylib
Referenced from: /usr/local/bin/identify
Reason: Incompatible library version: identify requires version 14.0.0 or later, but libfreetype.6.dylib provides version 13.0.0
Trace/BPT trap: 5
我认为我的问题不在Paperclip上,而是在通过Homebrew安装ImageMagick时出现了问题。
我已经尝试了所有建议的方法,包括:
brew update
brew remove imagemagick
brew install imagemagick
但这并没有帮助我,我正在运行的是Lion 10.7.2,并已安装了开发者工具。
非常感谢您提供任何建议。