Jono.Brain-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Sep-14 16:42 UTC
Filecolumn resize help
Hi I am using file column to upload and create some resized images however I can''t figure out how to crop to a certain size. What I want to do is take the uploaded image and create a thumb 110px x 85px. I want the thumb to be cropped and not be stretched. I also want it to create a version 560px x 300px again cropping the image and not stretching it. The uploaded image will sometimes be taller and sometimes wider. Is this possible using file_column? Any help much appreciated, its starting to drive me crazy. Thanks Jono. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jono.Brain-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> Hi > > I am using file column to upload and create some resized images however > I can''t figure out how to crop to a certain size. > > What I want to do is take the uploaded image and create a thumb 110px x > 85px. I want the thumb to be cropped and not be stretched. > > I also want it to create a version 560px x 300px again cropping the > image and not stretching it. > > The uploaded image will sometimes be taller and sometimes wider. > > Is this possible using file_column? > > Any help much appreciated, its starting to drive me crazy. > > Thanks > > Jono. >I haven''t used the cropping ability yet but I think there are a couple of examples on the file_column and the rmagick website. But, check out the following link that has a cropping example: http://addictedtonew.com/archives/127/rotating-images-with-rmagick-and-ruby-on-rails/ Cheers mohit. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jono.Brain@... <Jono.Brain@...> writes:> What I want to do is take the uploaded image and create a thumb 110px x > 85px. I want the thumb to be cropped and not be stretched. > > I also want it to create a version 560px x 300px again cropping the > image and not stretching it.Assuming you have RMagick installed, this is easy :) file_column :photo, :rmagick => { :versions => { :thumb => {:crop => "110:85", :size => "110x"}, # :size => "WWxHH" # but either can be omitted if you want the other # dimension calculated :medium => {:crop => "28:15", :size => "560x"} # :crop is a ratio # and cropping is done before resizing } } Gareth --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Gareth/Mohit Thankyou for your replies, this now makes perfect sense, the Aspect Ratio was confusing me before. The code is at home so I will have to wait to try it, but I''m pretty confident this will do the jobs nicely. Thanks Jono. On 14/09/06, Gareth Adams <gareth.adams-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Jono.Brain@... <Jono.Brain@...> writes: > > > What I want to do is take the uploaded image and create a thumb 110px x > > 85px. I want the thumb to be cropped and not be stretched. > > > > I also want it to create a version 560px x 300px again cropping the > > image and not stretching it. > > Assuming you have RMagick installed, this is easy :) > > file_column :photo, :rmagick => { > :versions => { > :thumb => {:crop => "110:85", :size => "110x"}, # :size => "WWxHH" > # but either can be omitted if you want the other > # dimension calculated > :medium => {:crop => "28:15", :size => "560x"} # :crop is a ratio > # and cropping is done before resizing > } > } > > Gareth > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---