关于此问题有很多Stackoverflow问题,但经过几个小时后,我已经筋疲力尽了我能想到的每一个角度,当我尝试使用PaperClip gem上传图像时仍然会出现以下错误(与PaperCrop一起,用于裁剪图像)。
Paperclip::Errors::NotIdentifiedByImageMagickError - Paperclip::Errors::NotIdentifiedByImageMagickError:
paperclip (4.3.6) lib/paperclip/geometry_detector_factory.rb:10:in `make'
paperclip (4.3.6) lib/paperclip/geometry.rb:26:in `from_file'
papercrop (0.3.0) lib/papercrop/model_extension.rb:95:in `image_geometry'
papercrop (0.3.0) lib/papercrop/helpers.rb:45:in `cropbox'
app/views/users/_crop_photo_modal.html.haml:12:in `block in _app_views_users__crop_photo_modal_html_haml___1410212035753490924_70365684359680'
以下是错误发生之前在日志中打印的内容:
[AWS S3 200 0.554305 0 retries] head_object(:bucket_name=>"XXX-development-bucket-us",:key=>"profiles/profile_images/1/original/main_sized_small.png")
[AWS S3 200 0.049585 0 retries] head_object(:bucket_name=>"XXX-development-bucket-us",:key=>"profiles/profile_images/1/thumb/main_sized_small.png")
[AWS S3 200 0.053507 0 retries] head_object(:bucket_name=>"XXX-development-bucket-us",:key=>"profiles/profile_images/1/medium/main_sized_small.png")
[AWS S3 200 0.048024 0 retries] head_object(:bucket_name=>"XXX-development-bucket-us",:key=>"profiles/profile_images/1/large/main_sized_small.png")
Command :: PATH=/usr/local/bin/:$PATH; file -b --mime '/tmp/3aa49ec6bfc910647fa1c5a013e48eef20160601-82031-t5fq8a.png'
Command :: PATH=/usr/local/bin/:$PATH; identify -format '%wx%h,%[exif:orientation]' '/tmp/3aa49ec6bfc910647fa1c5a013e48eef20160601-82031-1kh6s2w.png[0]' 2>/dev/null
Command :: PATH=/usr/local/bin/:$PATH; identify -format %m '/tmp/3aa49ec6bfc910647fa1c5a013e48eef20160601-82031-1kh6s2w.png[0]'
Command :: PATH=/usr/local/bin/:$PATH; convert '/tmp/3aa49ec6bfc910647fa1c5a013e48eef20160601-82031-1kh6s2w.png[0]' -auto-orient -resize "50x" -crop "50x50+0+0" +repage '/tmp/96994f01b3cacc5ddb9ed35b539d8c0420160601-82031-1n0cfvq'
Command :: PATH=/usr/local/bin/:$PATH; identify -format '%wx%h,%[exif:orientation]' '/tmp/3aa49ec6bfc910647fa1c5a013e48eef20160601-82031-1kh6s2w.png[0]' 2>/dev/null
Command :: PATH=/usr/local/bin/:$PATH; identify -format %m '/tmp/3aa49ec6bfc910647fa1c5a013e48eef20160601-82031-1kh6s2w.png[0]'
Command :: PATH=/usr/local/bin/:$PATH; convert '/tmp/3aa49ec6bfc910647fa1c5a013e48eef20160601-82031-1kh6s2w.png[0]' -auto-orient -resize "100x" -crop "100x100+0+0" +repage '/tmp/96994f01b3cacc5ddb9ed35b539d8c0420160601-82031-1fnck50'
Command :: PATH=/usr/local/bin/:$PATH; identify -format '%wx%h,%[exif:orientation]' '/tmp/3aa49ec6bfc910647fa1c5a013e48eef20160601-82031-1kh6s2w.png[0]' 2>/dev/null
Command :: PATH=/usr/local/bin/:$PATH; identify -format %m '/tmp/3aa49ec6bfc910647fa1c5a013e48eef20160601-82031-1kh6s2w.png[0]'
Command :: PATH=/usr/local/bin/:$PATH; convert '/tmp/3aa49ec6bfc910647fa1c5a013e48eef20160601-82031-1kh6s2w.png[0]' -auto-orient -resize "220x" -crop "220x220+0+0" +repage '/tmp/96994f01b3cacc5ddb9ed35b539d8c0420160601-82031-e3r9iy'
Command :: PATH=/usr/local/bin/:$PATH; file -b --mime '/tmp/3aa49ec6bfc910647fa1c5a013e48eef20160601-82031-ub7nk7.png'
(0.4ms) ROLLBACK
Command :: PATH=/usr/local/bin/:$PATH; identify -format '%wx%h,%[exif:orientation]' 'https://XXX-development-bucket-us.s3.amazonaws.com/profiles/profile_images/1/original/blake.png?1464811715[0]' 2>/dev/null
我的环境:
我尝试了以下内容:
在模型中直接包含:s3_credentials和:s3_permissions,如下所示:
has_attached_file:profile_image, :styles => {:thumb => “50x50#”,:medium => “100x100#”,:large => “220x220#”}, :storage => :S3, :s3_credentials => {:bucket => “XXX-development-bucket-us”,:access_key_id => “XXX”,:secret_access_key => “XXX”}, :s3_permissions => “公众阅读的”, :default_url => '/images/:attachment/missing_:style.jpg' validates_attachment:profile_image,content_type:{content_type:[“image / jpg”,“image / jpeg”,“image / png”]} crop_attached_file:profile_image,:aspect => “1:1”
我认为这可能是一个s3权限问题,但我们的开发存储桶上的权限应允许对密钥所标识的用户进行所有访问。
我还添加了......
Paperclip.options [:command_path] =“/ usr / local / bin”
...到environment / development.rb。
我已经验证了ImageMagick正在使用命令行。
还有什么想法可以看看吗?
答案 0 :(得分:0)
是的,有许多现有的答案有不同的建议。但是我试了一天所有可能的解决方案,并找到了适合我的解决方案。
Ubuntu 12.04,Paperclip~> '4.2'
最初我正在使用ImageMagick 6.6.9-7 2016-06-01 Q16,将其更新为ImageMagick 7.0.3-1 Q16 x86_64 2016-09-27修复它。
注意:尝试使用wget http://www.imagemagick.org/download/ImageMagick.tar.gz