So I have a Rails 3 app using Paperclip to crop images.
I have this code in my model for Photo:
has_attached_file :thumbnail, PAPERCLIP_OPTIONS.merge(
:styles => {:cropped => '300x250#'})
The resulting image that's generated creates a 300x250 image, however the crop seems to always start a good 50px or so below the top of the image (not a good thing for social networking when it cuts off the top of peoples heads).
I did some research and I'm thinking I need to supply a :convert_options key that coincides with the :cropped style. However, I don't know exactly what options to set (-gravity, -region, etc.)
Anybody have any thoughts. I know there are Imagemagick pros; I'm not one, lol.
Thanks!
Update: I found this link.. http://forrst.com/posts/Customized_Cropping_with_Paperclip-7g6
Is this still valid or does somebody have a better easier way?
Here's my favorite way to do it:
:styles => { :large => "", :medium => "", :thumb => ""},
:convert_options => {
:large => "-gravity north -thumbnail 300x300^ -extent 300x300" ,
:medium => "-gravity north -thumbnail 200x200^ -extent 200x200",
:thumb => "-gravity north -thumbnail 100x100^ -extent 100x100"
}
Note that instead of # you use ^ + extent.
Gravity parameters are like on a map: north, northeast, east ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With