I''m using attachment_fu in some code that allows photo upload. The attachment_fu Model code generally looks like this: has_attachment :content_type => :image, :storage => :file_system, :max_size => 100.kilobytes, :resize_to => ''146x68>'', :processor => ''Rmagick'' However, we want to accept uploads in either portrait or landscape mode, and have them resized appropriately (such as resized to 200x150 if it''s landscape, or 150x200 if it''s portrait). Looking at attachment_fu, though, it doesn''t look like it will handle that, resizing to the required dimensions regardless of orientation. Has anyone done something like this before? Any thoughts? I figure I can always resize in two directions and then pick the one to display, but there seems like there''d be a better way to do that. --Wade --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
H. Wade Minter wrote:> I''m using attachment_fu in some code that allows photo upload. The > attachment_fu Model code generally looks like this: > > has_attachment :content_type => :image, > :storage => :file_system, > :max_size => 100.kilobytes, > :resize_to => ''146x68>'', > :processor => ''Rmagick'' > > However, we want to accept uploads in either portrait or landscape > mode, and have them resized appropriately (such as resized to 200x150 > if it''s landscape, or 150x200 if it''s portrait). Looking at > attachment_fu, though, it doesn''t look like it will handle that, > resizing to the required dimensions regardless of orientation. > > Has anyone done something like this before? Any thoughts? I figure > I can always resize in two directions and then pick the one to > display, but there seems like there''d be a better way to do that.You didn''t say whether your system was ImageMagick/RMagick based, but if it is, simply saying :resize_to => "200x200" should work. By default, ImageMagick maintains the aspect ratio when it resizes. --Al Evans -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
H. Wade Minter
2007-May-10 00:32 UTC
Re: attachment_fu and portrait vs. landscape pictures
On May 9, 2007, at 7:45 PM, Al Evans wrote:> > H. Wade Minter wrote: >> I''m using attachment_fu in some code that allows photo upload. The >> attachment_fu Model code generally looks like this: >> >> has_attachment :content_type => :image, >> :storage => :file_system, >> :max_size => 100.kilobytes, >> :resize_to => ''146x68>'', >> :processor => ''Rmagick'' >> >> However, we want to accept uploads in either portrait or landscape >> mode, and have them resized appropriately (such as resized to 200x150 >> if it''s landscape, or 150x200 if it''s portrait). Looking at >> attachment_fu, though, it doesn''t look like it will handle that, >> resizing to the required dimensions regardless of orientation. >> >> Has anyone done something like this before? Any thoughts? I figure >> I can always resize in two directions and then pick the one to >> display, but there seems like there''d be a better way to do that. > > > You didn''t say whether your system was ImageMagick/RMagick based, > but if > it is, simply saying :resize_to => "200x200" should work. By default, > ImageMagick maintains the aspect ratio when it resizes.Thanks for the suggestion, but I should have mentioned that we''re doing a resize-and-crop via rmagick, which means that we don''t want to (exactly) preserve the aspect ratio. The image will be resized and cropped to exactly 200x150 if it''s landscape, and exactly 150x200 if it''s portrait. Which does complicate things. I''ve got the resize-and-crop working, it''s just trying to figure out how to do one or the other depending on its orientation. --Wade --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---