Image Paperclip :: Errors :: NotIdentifiedByImageMagickError #Windows [英] Image Paperclip::Errors::NotIdentifiedByImageMagickError #Windows

查看:159
本文介绍了Image Paperclip :: Errors :: NotIdentifiedByImageMagickError #Windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm getting tired of this error... I tried everything that's on the internet (that I found so far)

Gem

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

config / environments / development.rb

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的路径

path for ImageMagick/convert

https://gyazo.com/2e8714546606b796b63f5b64663cab31

它安装的file.exe

file.exe it installed

https://gyazo.com/5d0d3d5723c52e6cc812d72202ba4038

我的模特

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


推荐答案

这可能有点晚了。
有很多人遇到此问题正在运行Windows。

This might be a little late. Lots of people with this issue are running Windows.


  1. 图像Magick应该正确安装(安装期间选择所有选项)。这是重新安装和重新启动的重要一步,所以请将此选项留到最后。

  2. 打开 config / environments / development.rb

  3. 添加以下行:`Paperclip.options [:command_path] ='C:\Program Files(x86)\ GNnWin32 \ bin'。您可以通过在命令行运行转换来检查路径(显示我的路径)。不是Windows附带的命令行。我运行git bash。

  4. 重启你的Rails服务器

  5. 检查你的模型。我在app\models\post.rb中的语法是

    has_attached_file:image,styles:{medium:300x300>,thumb:100x100> }

  1. Image Magick should be installed correctly (all options selected during install). It is a big step to reinstall and reboot so leave this option until last.
  2. Open config/environments/development.rb
  3. Add the following line: `Paperclip.options[:command_path] = 'C:\Program Files (x86)\GnuWin32\bin'. You check the path (mine is shown) by running which convert at the command line. Not the command line that ships with windows. I run git bash.
  4. Restart your Rails server
  5. Check your model. My syntax in app\models\post.rb was has_attached_file :image, styles: { medium: "300x300>", thumb: "100x100>" }

我改为


has_attached_file:image,style:{:medium => 300x300>,:thumb => 100×100> 中}


  1. 您可能会发现错误消失但图像未显示。检查显示页面中的代码。


    • 如果我删除(:中等)图像显示正常。

    • 当我离开时,它没有显示代码如下(Haml,对不起!)

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

这篇关于Image Paperclip :: Errors :: NotIdentifiedByImageMagickError #Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆