Rectangle clip and trim

So, I expect a series of photographs of different sizes and proportions. I want to be able to compress / stretch a photo so that it can be in a 200x100 rectangle, and then crop the rest, which is not suitable. I want the crop to occur around the center. Is it possible? I am so confused by the documentation to imagine.

Thanks!

+6
source share
2 answers

Folder # will do exactly what you want: fit the image as much as possible within the specified dimensions, then circle the excess with gravity in the center.

Example:

 has_attached_file :photo, :styles => { :original => "200x100#" } 

Note. . If you want to keep the original intact and create an extra cropped finger, simply change the :original key to something else, for example :thumb .

Link: http://rdoc.info/github/thoughtbot/paperclip/Paperclip/ClassMethods

+18
source

Source: https://habr.com/ru/post/906075/


All Articles