Rails Paperclip - Can't get thumbnail to resize properly
I'm having difficulty creating a thumbnail, for some reason it's not chopping off the way I want. I typic开发者_如何学Cally post landscape photos so the dimensions are correct, however when the photo has to be auto rotated, it's not working.
has_attached_file :image, :styles => { :mobile_lg => "640x480>",
:mobile_sm => "200x150#",
:thumb => "96x96#"
},
:convert_options => { :all => '-auto-orient' },
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => "/:style/:id/:filename"
Don't laugh at the pic, it's my only example! Here's the mobile_lg
photo.
and the mobile_sm
photo:
When the thumbnail should be like this (i cropped it like this in Photoshop)
I've tried to add this after the styles, but it's not working.
:commands => { :mobile_sm => "-gravity center -extent 200x150#" }
I would like to take the photo and crop/resize it to 200(width) by 150(height), even if it means doing it destructively. I've also tried to use !
after the dimensions, but still I get the mobile_sm image you see above.
I guess you're looking for something like:
:small => { :mobile_sm => '150x200!', :quality => 70, :format => 'JPG'}
Have a look here: http://www.imagemagick.org/script/command-line-processing.php
It sums up everything you can do with ImageMagick used by Paperclip.
BTW, I like the pic ;)
精彩评论