Image Paperclip::Errors::NotIdentifiedByImageMagickError #Windows

╄→гoц情女王★ 提交于 2019-12-24 13:44:18

问题


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

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

path for ImageMagick/convert

https://gyazo.com/2e8714546606b796b63f5b64663cab31

file.exe it installed

https://gyazo.com/5d0d3d5723c52e6cc812d72202ba4038

my model

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

回答1:


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

  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>" }

which I changed to

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

  1. You may find the error goes but the image is not showing. Check your code in the show page.
    • If I remove (:medium) the image shows fine.
    • It doesn't show when I leave the code like below (Haml, sorry!)

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



来源:https://stackoverflow.com/questions/37264425/image-papercliperrorsnotidentifiedbyimagemagickerror-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!