我正在使用Heroku和Amazon AWS(S3)在线迁移我的应用程序,并遇到了我的profilepic
模型的奇怪错误。使用Amazon S3时出现回形针错误
此模型管理配置文件图片。它由2个回形针附件和一些其他字段组成,并取决于另一个型号Professionnel
。
下面是该模型:
class Profilepic < ApplicationRecord
belongs_to :professionnel
has_attached_file :image, styles: { original: "6000x6000", editable: "1200x1200", thumbnail: "400x400#"}
validates_attachment :image, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] }, size: {less_than: 10.megabytes}
has_attached_file :finalimage, styles: { medium: "500x500", small: "200x200"}, processors: [:cropper]
attr_accessor :crop_x, :crop_y, :crop_w, :crop_h
end
第一附接:图像是由用户上载的图像。第二图像(:finalimage)是
一切局部正常使用
虽然,当图像被上传下面的代码位被返回Professionnel
用户编辑它(与cropper.js)之后的裁剪后的图像回形针::错误:: NotIdentifiedByImageMagickError
的触发此错误代码位是:
nouvelleppic.ratiolongdivlarg = Paperclip::Geometry.from_file(nouvelleppic.image.path(:original)).width/Paperclip::Geometry.from_file(nouvelleppic.image.path(:original)).height
在此位的代码,我discove在Paperclip几何函数的帮助下响应宽高比。
不知道什么是错的。它确实在本地工作,我正在查询此后:图像被成功保存到我的S3桶(我在S3控制台检查)
我需要这个比例创建的视图,将允许用户裁剪图像和转它进入:finalimage。这真的很有趣,它迁移到Heroku/S3时不起作用,因为它是一个来自Paperclip的简单几何函数。没问题上传...
编辑编辑
似乎找到问题:
https://github.com/thoughtbot/paperclip/issues/2198
我只是检查了我的Heroku Cedar14 ImageMagick的版本堆:6.7.7-10 !
Version: ImageMagick 6.7.7-10 2016-11-29 Q16 http://www.imagemagick.org
正如上面的git线程所建议的,有没有一种方法可以在Heroku上升级ImageMagick?
此线程How can I use the latest version of Imagemagick on Heroku?似乎暗示我们可以做到这一点(第二个答案)?
感谢您对本。这是很好的知道我可以更改ImageMagick版本。虽然我甚至不确定它会解决我的问题。将尝试在git Thread中提到的修复。这是比我能做的更先进的Ruby,但我会试试看。 – Maxence
一个愚蠢的事情:我检查远程存储的图像的尺寸。尽管模型尚未保存,然后图像尚未用回形针处理,是否无法检查此事件?像临时文件? – Maxence
该死的了! http://stackoverflow.com/questions/4065295/saving-the-images-dimensions-width-and-height-in-paperclip – Maxence