# Filecolumn resize help

**URL:** <https://www.ruby-forum.com/t/filecolumn-resize-help/68715>\
**Category:** Rails\
**Created:** [September 14, 2006, 6:47pm UTC](https://www.ruby-forum.com/t/filecolumn-resize-help/68715 "2006-09-14T18:47:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 14, 2006, 6:47pm UTC](https://www.ruby-forum.com/t/filecolumn-resize-help/68715/1 "2006-09-14T18:47:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 14, 2006, 6:57pm UTC](https://www.ruby-forum.com/t/filecolumn-resize-help/68715/2 "2006-09-14T18:57:04Z")

</div>

removed\_email\_address@domain.invalid 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/](http://addictedtonew.com/archives/127/rotating-images-with-rmagick-and-ruby-on-rails/)

Cheers  
mohit.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 15, 2006, 12:47pm UTC](https://www.ruby-forum.com/t/filecolumn-resize-help/68715/3 "2006-09-15T12:47:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 14, 2006, 11:48pm UTC](https://www.ruby-forum.com/t/filecolumn-resize-help/68715/4 "2006-09-14T23:48:39Z")

</div>

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
