问题
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.
- 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.
- Open
config/environments/development.rb
- 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. - Restart your Rails server
- 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>" }
- 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