# Attachement\_fu width and height ratio

**URL:** <https://www.ruby-forum.com/t/attachement-fu-width-and-height-ratio/171408>\
**Category:** Rails\
**Created:** [July 1, 2009, 11:57pm UTC](https://www.ruby-forum.com/t/attachement-fu-width-and-height-ratio/171408 "2009-07-01T23:57:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shuaib85](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@shuaib85](https://www.ruby-forum.com/u/shuaib85)\
**Post date:** [July 1, 2009, 11:57pm UTC](https://www.ruby-forum.com/t/attachement-fu-width-and-height-ratio/171408/1 "2009-07-01T23:57:59Z")

</div>

Hi there

I am wondering on how can i thumbnail the pictures height and width  
based on ratio

let’s say that my design is limited to a fixed size. and I want to  
keep the image looks nice and not stretched. e.g. the width is 200 and  
the height is 200

in case that i have an image that is tall, it will break the design. I  
am looking for a way on how to check which is bigger the width or the  
height and based on that make the thumbnail

Thanks

---

<div class="post-metadata">

**Author:** ![shuaib85](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@shuaib85](https://www.ruby-forum.com/u/shuaib85)\
**Post date:** [July 2, 2009, 12:10am UTC](https://www.ruby-forum.com/t/attachement-fu-width-and-height-ratio/171408/2 "2009-07-02T00:10:27Z")

</div>

Shuaib Z. wrote:

> Hi there
> 
> I am wondering on how can i thumbnail the pictures height and width  
> based on ratio
> 
> let’s say that my design is limited to a fixed size. and I want to  
> keep the image looks nice and not stretched. e.g. the width is 200 and  
> the height is 200
> 
> in case that i have an image that is tall, it will break the design. I  
> am looking for a way on how to check which is bigger the width or the  
> height and based on that make the thumbnail
> 
> Thanks

IIRC, the resize option of  
:thumbnails =\> { :thumb =\> ‘100x100\>’}

keeps the aspect ratio (at least with Rmagick / Imagemagick)…  
1024x768 becomes roughly 100x75, while 500x768 becomes roughly 65x100.
