I am migrating my application online with Heroku and Amazon AWS (S3) and encountered a weird error for my profilepic
model.
This model manages the profile pic. It is made of 2 Paperclip attachments and a few other fields and depends to another model called Professionnel
.
Here is the model :
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
First attachment :image is the image uploaded by the user. The second image (:finalimage) is a cropped image after Professionnel
user has edited it (with cropper.js)
Everything is working perfectly locally
Though, when the image is uploaded the following bit of code is returning Paperclip::Errors::NotIdentifiedByImageMagickError
The bit of code that triggers this error is :
nouvelleppic.ratiolongdivlarg = Paperclip::Geometry.from_file(nouvelleppic.image.path(:original)).width / Paperclip::Geometry.from_file(nouvelleppic.image.path(:original)).height
In this bit of code, I am discovering the width/height ratio with help from Paperclip geometry functions.
Not sure what's wrong. It does work locally flawlessly and I am querying this AFTER the :image is successfully saved into my S3 bucket (I checked in S3 console)
I need this ratio to create the view that will allow user to crop the image and turn it into :finalimage. This is really funny it doesn't work when migrationg to Heroku / S3 as it is a simple geometry function from Paperclip. No problem uploading ...
EDIT EDIT
seems the problem is identified :
https://github.com/thoughtbot/paperclip/issues/2198
I just checked the Imagemagick version on my Heroku Cedar14 stack: 6.7.7-10 !!
Version: ImageMagick 6.7.7-10 2016-11-29 Q16 http://www.imagemagick.org
as suggested in the git thread above, is there a way to upgrade ImageMagick at Heroku ??
This thread How can I use the latest version of Imagemagick on Heroku? seems to suggest we can do that (second answer) ??