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.

[email protected] wrote:

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.

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.

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 :slight_smile:

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