4

尝试将png保存到带回形针附件的模型时出现错误。“识别”命令无法识别Rails回形针`

User型号:

class User < ActieRecord::Base 
    attr_accessible :icon 
    has_attached_file :icon, :url => "/system/users/icon/:hash.:extension", 
    :hash_secret => "superSecretHashSecret", 
    :styles => { :medium => "300x300>", :thumb => "100x100>" } 
end 

试图设置图标示例:

u = User.last 
u.icon = open(Rails.root + "spec/fixtures/files/example.png") 
u.save 

例模型误差:

:icon => ["/var/folders/43/810gn/T/example20121104-36855-1v7t136.png is not recognized by the 'identify' command."] 

还有谁已经张贴了许多人类似的问题,尤其是this one,但没有一个e解决方案为我工作。

我command_path是否设置正确:

O:~ $ which identify 
/usr/local/bin/identify 

development.rb

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

这可能仍然是,虽然这个问题。 当试图使用`直接出现以下错误鉴定:这到底是怎么回事

O:~ $ identify workspace/app/spec/fixtures/files/example.png 
dyld: Library not loaded: /usr/lib/libltdl.7.dylib 
    Referenced from: /usr/local/bin/identify 
    Reason: image not found 
Trace/BPT trap: 5 

任何建议?

我曾尝试重新安装的ImageMagick

brew unlink imagemagick 
brew install imagemagick 

其他人推荐加入Rmagick。这绝对不是使用回形针的要求,也没有帮助。

已提出的另一个解决方案是删除:style属性。但这不是一个解决方案。我需要对图像进行处理。

我有Paperclip处理另一个模型在我的项目中处理文件不是图像/不做任何处理。所以我知道这可能与此有关。

有关如何解决此问题的其他建议?

回答

4

解决方案最终要安装libtool。这也是最好的建议here。我的问题被证明更复杂,因为homebrew不是最新的,并且在不强制结算主人的情况下无法更新。

对于将来会遇到此问题的人员,我建议您手动检查identify命令是否实际工作,即使它在您的路径中也是如此。

identify /path/to/some/image 

如果失败了,它会显示类似:

O:~ $ identify workspace/app/spec/fixtures/files/example.png 
dyld: Library not loaded: /usr/lib/libltdl.7.dylib 
    Referenced from: /usr/local/bin/identify 
    Reason: image not found 
Trace/BPT trap: 5 

在这种情况下尝试安装libtool

brew install libtool 

如果失败,请运行brew update。如果它继续失败,请确保已安装最新的Xcode并再次尝试更新。

如果您可以成功使用identity,您将会知道该功能。它看起来是这样的:

O:~ $ identify ~/workspace/app/spec/fixtures/files/example.png 
~/workspace/app/spec/fixtures/files/example.png PNG 200x201 200x201+0+0 8-bit DirectClass 66.1KB 0.000u 0:00.000 

glebm的答案可能很有效。我没有看过那个安装程序。

9

这是一个ImageMagick安装问题。

首先尝试

brew update 
brew upgrade imagemagick 

如果不工作,使用magick安装程序脚本来解决这个问题: https://github.com/maddox/magick-installer

curl https://raw.github.com/maddox/magick-installer/master/magick-installer.sh | sh 

另外,使用magick安装程序的用叉子更新版本的依赖库:

curl https://raw.github.com/GTSouza/magick-installer/master/magick-installer.sh | sh 
+0

感谢glebm。我通过直接与自制啤酒争论了一段时间(似乎这可能为我节省了麻烦)。 –

+0

谢谢! magick-installer脚本为我工作。 – sq1020

0

这可能是由于旧版本的Paperclip与可卡因宝石的新版本和不兼容版本一起使用造成的。您可以使用bundle update paperclip来更新回形针宝石版本。它将根据兼容性更新回形针和可卡因版本。

https://github.com/thoughtbot/paperclip/issues/1038

0

我只是碰到了同样的问题升级到小牛在我的Mac之后。

这里有固定的问题的步骤:

brew update 
brew install libtool 
brew link libtool 
brew upgrade imagemagick