gpt4 book ai didi

ruby-on-rails - Rails 回形针 `is not recognized by the ' 识别'命令`

转载 作者:行者123 更新时间:2023-12-04 05:31:55 25 4
gpt4 key购买 nike

尝试将 png 保存到带有回形针附件的模型时出现错误。

我的 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,但这些解决方案都不适用于我。

我的 command_path 设置正确:
O:~ $ which identify
/usr/local/bin/identify

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

但这仍然可能是问题所在。
尝试直接使用 `identify 时,出现以下错误:
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 。这绝对不是使用 Paperclip 的必要条件,它也没有帮助。

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

我有 Paperclip 在我的项目中处理另一个模型,该模型处理非图像/不进行任何处理的文档。所以我知道这可能与此有关。

关于如何解决这个问题的任何其他建议?

最佳答案

这是 ImageMagick 安装问题。

第一次尝试

brew update
brew upgrade imagemagick

如果这不起作用,请使用 magick-installer 脚本来解决这个问题:
https://github.com/maddox/magick-installer
curl https://raw.github.com/maddox/magick-installer/master/magick-installer.sh | sh

或者,使用带有较新版本依赖库的 magick-installer 的分支:
curl https://raw.github.com/GTSouza/magick-installer/master/magick-installer.sh | sh

关于ruby-on-rails - Rails 回形针 `is not recognized by the ' 识别'命令`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13223973/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com