views:

22

answers:

2

Our site takes many different sized thumbnails and converts them to squares for sorting. The squares are 135px x 135px.

Our current setup:

:styles => { 
  :thumbnail => '135x>'
}

As you can see, this is downsizing the image to 135px height (while keeping the aspect ratio), the foces the width to 135px causing the image to become totally distorted.

Does anyone have a better way to do this? in particular with Imagemagick?

+2  A: 

:thumbnail => '135x135#' (note the #hashmark instead of >angle bracket) is how you'd take the middle 135px chunk as a thumbnail. If you want to scale and then crop, use a custom processor. If you know that the incoming images will already by 135px on one axis, then the above directive is enough to chop the ends off, wherever they may be.

Eric Hill
A: 

What file attachment system are you using? Paperclip, AttachmentFu, something else? If you're using rmagick to call Imagemagick, then a custom processor using the crop_resized! method may give you what you're looking for.

jwarchol