So I am expecting a series of photos of different sizes and aspect ratios. I want to be able to shrink/stretch the photo to fit as much as it can in a 200x100 rectangle and then crop the rest that does not fit. I want the crop to happen around the center as well. Is this possible? I am so confused with the imagemagick documentation.
Thanks!
Paperclip's #
option will do exactly what you want: fit the image maximally within the specified dimensions then crop the excess with gravity at the center.
Example:
has_attached_file :photo,
:styles => {
:original => "200x100#"
}
Note: If you want to keep the original intact and generate an additional cropped thumb, just change the :original
key to something else, like :thumb
.
Reference: http://rdoc.info/github/thoughtbot/paperclip/Paperclip/ClassMethods
are any of these usefull?
Resize an image with Paperclip
Simple cropping with Paperclip
http://mfischer.com/wordpress/2009/02/02/multiple-image-upload-and-crop-with-rails/comment-page-1/
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