views:

898

answers:

1

I upload a photo, it is a rectangle. How Can I get it resized and filled to a square ?

I mean when the photo is horizontal positioned it should have above and under it, two white fields (for keeping the shape of a square) and when it is vertically, it should have two white fields on the sides of the photo.

When I used PHP, a have used this http://www.verot.net/php_class_upload_samples.htm

Have a look at the

100x150, keeping ratio, filling top and bottom

example

I'm using Paperclip with RoR. How is the best way to do that ?

A: 

You need to define a style. Here's an example.

Simone Carletti
Yes, I know, but how to do this ? http://www.imagemagick.org/Usage/thumbnails/#fit
astropanic
has_attached_file :picture, :styles => { :custom => "100x100>" }
Simone Carletti
this does'n center the image in the square box
astropanic
:convert_options => { :thumb => '-background white -gravity center -extent 50x50' }this works for me, thanks weppos
astropanic