Take the 2-minute tour ×

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.


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?

share|improve this question
add comment

1 Answer

up vote 9 down vote accepted

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 ...

share|improve this answer
You are amazing! I was looking for this forever. On to reprocessing all my production images :( –  Ben Scheib Nov 21 '11 at 23:12
Works great! Thanks for the detailed instructions. –  Brendon Muir Jun 10 '13 at 0:22
add comment

Your Answer


