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 ?
[Alt] J P V C (note that you don't hold down the alt key, you click it like a key).
Here's what I used on a rails 3 app w/ paperclip. I used the following ImageMagick options to make it centered: background, compose, gravity and extent. I'm using the mini_magick processor.
has_attached_file :image,
:styles => { :large => ["855x570>", :jpg], :medium => ["432x288>", :jpg], :small => ["276x184>", :jpg], :tiny => ["195x130>", :jpg] },
:processor => "mini_magick",
:convert_options => {
:medium => "-background white -compose Copy -gravity center -extent 432x288",
:small => "-background white -compose Copy -gravity center -extent 276x184",
:tiny => "-background white -compose Copy -gravity center -extent 195x130"
}
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