Paperclip: How to change "#" modifier behavior?
I use Paperclip 2.3.11 in my Rails 3 application, and I create thumbnails using:
:styles => { :thumb => "80x80#" }
However, if the picture is small, say 32x32
, it is enlarged to fit thumbnail dimensions.
I would like to fix that by hac开发者_如何学JAVAking Paperclip.
Unfortunately, I couldn't find the relevant code that describes #
's behavior.
Could you please point me to the right place in Paperclip code ?
Or, maybe there is a better solution ? I would like the thumbnails to be 80x80
unless the original picture is too small (in which case the thumbnail should be the same size as the original picture).
So, #
is an argument used by Paperclip to know whether or not you expect the pic to be cropped.
It's written here, through the crop?
method, itself looking at geometry[-1,1]
: basically the last character of the style you enter.
You could then:
try what's suggested by @David Sulc which seems ok regarding my previous explanation
dig further in Paperclip's code and maybe rewrite
transformation_to
defined here
Did you try :styles => { :thumb => "80x80>#" }
? (Sorry, can't try it out myself...)
You can get more info of the Geometry String which is used by ImageMagick as in following: http://www.imagemagick.org/RMagick/doc/imusage.html
精彩评论