【问题标题】:Image Paperclip::Errors::NotIdentifiedByImageMagickError #Windows图像回形针::错误::NotIdentifiedByImageMagickError #Windows
【发布时间】:2016-05-16 22:45:32
【问题描述】:

我厌倦了这个错误...... 我尝试了互联网上的所有内容(到目前为止我发现的)

宝石

gem 'paperclip', '~> 4.3', '>= 4.3.6'

config/environments/development.rb

Paperclip.options[:command_path] = "/c/Program Files/ImageMagick-7.0.1-Q16/"
Paperclip.options[:command_path] = 'C:\Program Files (x86)\GnuWin32\bin'

ImageMagick/convert 的路径

https://gyazo.com/2e8714546606b796b63f5b64663cab31

它安装的file.exe

https://gyazo.com/5d0d3d5723c52e6cc812d72202ba4038

我的模特

has_attached_file :image, styles: { medium: "300x300>"}
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/

【问题讨论】:

    标签: ruby-on-rails imagemagick paperclip


    【解决方案1】:

    这可能有点晚了。 许多遇到此问题的人都在运行 Windows。

    1. Image Magick 应该正确安装(安装过程中选择了所有选项)。重新安装和重新启动是一个很大的步骤,因此请将此选项留到最后。
    2. 打开config/environments/development.rb
    3. 添加以下行:`Paperclip.options[:command_path] = 'C:\Program Files (x86)\GnuWin32\bin'。您可以通过在命令行运行which convert 来检查路径(显示了我的路径)。不是 Windows 附带的命令行。我运行 git bash。
    4. 重启 Rails 服务器
    5. 检查您的型号。我在 app\models\post.rb 中的语法是 has_attached_file :image, styles: { medium: "300x300>", thumb: "100x100>" }

    我改成了

    has_attached_file :image, style: { :medium => "300x300>", :thumb => "100x100>" }

    1. 您可能会发现错误消失但图像未显示。在显示页面中检查您的代码。
      • 如果我删除 (:medium) 图像显示正常。
      • 当我留下如下代码时它不显示(哈姆,对不起!)

    = image_tag @recipe.image.url(:medium), class: "recipe_image"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多