ImageMagick 不允许我上传 jpg
我正在运行 Paperclip 2.3.11 和 ImageMagick 6.7.1-1。 我正在将图像上传到 Amazon S3 帐户。
如果我上传 .png
文件,它可以正常工作,如果我上传 .jpg
文件,它就不行。
这是当我尝试上传 jpg 时在我的视图中生成的错误:
3 errors prohibited this post from being saved:
Photo /var/folders/k9/kw7hkdmx741cqrc1h6_qwc580000gp/T/stream20110817-6147-urdz8d-0.jpg is not recognized by the 'identify' command.
Photo /var/folders/k9/kw7hkdmx741cqrc1h6_qwc580000gp/T/stream20110817-6147-urdz8d-0.jpg is not recognized by the 'identify' command.
Photo /var/folders/k9/kw7hkdmx741cqrc1h6_qwc580000gp/T/stream20110817-6147-urdz8d-0.jpg is not recognized by the 'identify' command.
我的日志显示:
Started POST "/posts" for 127.0.0.1 at Wed Aug 17 20:35:12 -0400 2011
Processing by PostsController#create as HTML
Parameters: {"commit"=>"Create Post", "post"=>{"photo"=>#<ActionDispatch::Http::UploadedFile:0x10c64d900 @headers="Content-Disposition: form-data; name=\"post[photo]\"; filename=\"Stonehenge.jpg\"\r\nContent-Type: image/jpeg\r\n", @content_type="image/jpeg", @original_filename="Stonehenge.jpg", @tempfile=#<File:/var/folders/k9/kw7hkdmx741cqrc1h6_qwc580000gp/T/RackMultipart20110817-6147-1uad809-0>>, "title"=>"test", "description"=>"test"}, "authenticity_token"=>"V/EinZAi2NNYx7AokikTpQFkNtADNiauW5vcNGdhTug=", "utf8"=>"\342\234\223"}
[paperclip] identify -format %wx%h '/var/folders/k9/kw7hkdmx741cqrc1h6_qwc580000gp/T/stream20110817-6147-urdz8d-0.jpg[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /var/folders/k9/kw7hkdmx741cqrc1h6_qwc580000gp/T/stream20110817-6147-urdz8d-0.jpg is not recognized by the 'identify' command.>
以前有人遇到过这个吗?让我知道是否还有其他信息有帮助。
更新: 刚刚注意到 .jpg 文件在另一台计算机上可以正常上传(两台计算机分别运行 10.6/10.7)。这让我更加失落。我的另一台机器上可能配置错误?
I am running Paperclip 2.3.11 and ImageMagick 6.7.1-1.
I am uploading images to an Amazon S3 account.
If I upload a .png
file it works fine, if I upload a .jpg
it does not.
This is the error generated in my view when I try uploading a jpg:
3 errors prohibited this post from being saved:
Photo /var/folders/k9/kw7hkdmx741cqrc1h6_qwc580000gp/T/stream20110817-6147-urdz8d-0.jpg is not recognized by the 'identify' command.
Photo /var/folders/k9/kw7hkdmx741cqrc1h6_qwc580000gp/T/stream20110817-6147-urdz8d-0.jpg is not recognized by the 'identify' command.
Photo /var/folders/k9/kw7hkdmx741cqrc1h6_qwc580000gp/T/stream20110817-6147-urdz8d-0.jpg is not recognized by the 'identify' command.
And my log reads:
Started POST "/posts" for 127.0.0.1 at Wed Aug 17 20:35:12 -0400 2011
Processing by PostsController#create as HTML
Parameters: {"commit"=>"Create Post", "post"=>{"photo"=>#<ActionDispatch::Http::UploadedFile:0x10c64d900 @headers="Content-Disposition: form-data; name=\"post[photo]\"; filename=\"Stonehenge.jpg\"\r\nContent-Type: image/jpeg\r\n", @content_type="image/jpeg", @original_filename="Stonehenge.jpg", @tempfile=#<File:/var/folders/k9/kw7hkdmx741cqrc1h6_qwc580000gp/T/RackMultipart20110817-6147-1uad809-0>>, "title"=>"test", "description"=>"test"}, "authenticity_token"=>"V/EinZAi2NNYx7AokikTpQFkNtADNiauW5vcNGdhTug=", "utf8"=>"\342\234\223"}
[paperclip] identify -format %wx%h '/var/folders/k9/kw7hkdmx741cqrc1h6_qwc580000gp/T/stream20110817-6147-urdz8d-0.jpg[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /var/folders/k9/kw7hkdmx741cqrc1h6_qwc580000gp/T/stream20110817-6147-urdz8d-0.jpg is not recognized by the 'identify' command.>
Has anyone encountered this before? Let me know if any other info would be helpful.
UPDATE:
Just noticed that .jpg files do upload fine on a different computer (both are Macs running 10.6/10.7 respectively). This leaves me even more lost. What could be misconfigured on my other machine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该安装 ImageMagick 的 JPG 支持。
这里是 jpegsrc 和 ImageMagick 的其他来源:
You should install JPG support for ImageMagick.
Here is jpegsrc and other sources for ImageMagick:
终于解决了这个问题。基于@floor的回答。 ImageMagick 在本机上不支持 jpg。我必须卸载并重新安装,然后也卸载并重新安装 Rmagick。现在一切正常。
Finally got this fixed. Based on @floor's answer. ImageMagick did not have jpg support on this machine. I had to uninstall and reinstall, then uninstall and reinstall Rmagick as well. Everything is working now.