调整大小错误 - Paperclip :: Errors :: NotIdentifiedByImageMagickError [英] Resize Error - Paperclip::Errors::NotIdentifiedByImageMagickError
问题描述
我刚将paperclip安装到我的应用程序中以上传图像,一切运行正常,直到我尝试添加样式以使图像调整大小。 (我可以在添加此代码之前上传图片)
I just installed paperclip into my app to upload images, and everything was working well until I tried to add the styles to make the image resize. (I can upload images fine before I add this code)
在pins.rb上:
has_attached_file :image, styles: { medium: "300x300>" }
然后我将该类添加到_pin.html.rb:
I then added the class to on _pin.html.rb:
<td><%= image_tag pin.image(:medium) %></td>
但是现在,当我尝试上传图片时,我收到错误:
But now, when I try and upload an image, I get the error:
Paperclip::Errors::NotIdentifiedByImageMagickError
当我删除样式时,它工作正常(没有调整大小),但调整大小的东西搞砸了。我尝试了不同的文件类型和文件名。我在谷歌搜索过这个错误,所有的解决方案都不适合我。最受欢迎的是降级可卡因,但当我尝试它时,我收到消息:
When I remove the styles, it works fine (alebit not resized), but something in the resizing is messing it all up. I tried different file types and filenames. I have searched for this error on google, and all the solutions aren't working for me. The most popular was to downgrade Cocaine, but when I try that it I get the message:
Bundler could not find compatible versions for gem "cocaine":
In Gemfile:
paperclip (~> 3.4.1) ruby depends on
cocaine (~> 0.5.0) ruby
cocaine (0.3.2)
我的rails服务器正在返回消息:
My rails server is returning the message:
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2013-03-22 21:50:05 -0400
Served asset /application.js - 304 Not Modified (1ms)
[2013-03-22 21:50:05] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
任何帮助?如果有帮助,我可以在 https://github.com/jeremybelcher/omrails 的github上找到它。
Any help? I have it on github at https://github.com/jeremybelcher/omrails if that helps.
推荐答案
要回答Rich Peck的问题,您不必直接将其添加到模型中 - 您可以将其添加到/ config /环境/ development.rb。这样它只会影响您的开发版本,而不会影响您的生产版本。
To answer Rich Peck's question, you don't have to add it into the model directly - you can add it into /config/environments/development.rb. That way it'll only affect your dev version and not your production version.
所以在我的情况下,我刚刚添加了
So in my case, I just added
Paperclip.options [:command_path] ='C:\Program Files \ ImageMagick-6.8.7-Q16'
到我的config / environments / development.rb文件的末尾,它就像一个魅力。
to the end of my config/environments/development.rb file and it worked like a charm.
这篇关于调整大小错误 - Paperclip :: Errors :: NotIdentifiedByImageMagickError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!