How to scale thumbnail to fit depending on tall or wide photo - Attachment_fu

Posted by adamwstl on Stack Overflow See other posts from Stack Overflow or by adamwstl
Published on 2010-05-20T05:14:28Z Indexed on 2010/05/20 5:20 UTC
Read the original article Hit count: 183

I'm using attachment_fu and Rmagick to create thumbnails after upload. The thumbnail is a fixed 135 x 135 px and I'm currently forcing the width to 135px on all photos. The problem is that if it's a wide and fat photo is has to stretch the height awkwardly.

Current Attachment_fu setup

class PhotoImage < Image
belongs_to :photo

 has_attachment :content_type => :image,
   :size   => 0..5.megabytes, 
   :storage => :s3,
   :resize_to => '650x>',
   :thumbnails => { 
   :thumbnail => '135x>' }#:geometry => 'x50' }
 validates_as_attachment
end

Here's what I'm trying to do:

Thanks

© Stack Overflow or respective owner

Related posts about attachment-fu

Related posts about rmagick