# Attachment\_fu -- specify exact resize value

**URL:** <https://www.ruby-forum.com/t/attachment-fu-specify-exact-resize-value/92305>\
**Category:** Rails\
**Created:** [April 18, 2007, 2:50am UTC](https://www.ruby-forum.com/t/attachment-fu-specify-exact-resize-value/92305 "2007-04-18T02:50:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [April 18, 2007, 2:50am UTC](https://www.ruby-forum.com/t/attachment-fu-specify-exact-resize-value/92305/1 "2007-04-18T02:50:49Z")

</div>

How can you get the images and thumbnails to resize to an exact  
demension? This is what I have in my model:

:resize\_to =\> ‘150x150\>’,  
:thumbnails =\> { :thumb =\> ‘31x31\>’ }

If the images are not perfectly squared, I get sizes like 31x23 or  
112x150. I guess I would need the image to be cropped to become  
exactly 31x31. Any suggestions?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [April 18, 2007, 2:58am UTC](https://www.ruby-forum.com/t/attachment-fu-specify-exact-resize-value/92305/2 "2007-04-18T02:58:50Z")

</div>

You can remove the “\>” at the end there or use an array [31, 31]  
instead and it will squish the image to the size you want.

Cropping is not yet supported in the stable release of  
attachment\_fu… but if you are willing to do some editing in  
attachment\_fu .rb files here is a link so someone who claims they  
found a solution:

[http://www.deepcalm.com/writing/cropped-thumbnails-in-attachment\_fu-using-imagescience](http://www.deepcalm.com/writing/cropped-thumbnails-in-attachment_fu-using-imagescience)

Also here is something I found through a quick Google but I’m not sure  
if it’s any good either:

[http://jon-dahl.blogspot.com/2007/03/cropping-with-attachmentfu-ruby-on\_6063.html](http://jon-dahl.blogspot.com/2007/03/cropping-with-attachmentfu-ruby-on_6063.html)

Cheers.

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [April 18, 2007, 5:56am UTC](https://www.ruby-forum.com/t/attachment-fu-specify-exact-resize-value/92305/3 "2007-04-18T05:56:58Z")

</div>

Perfect, thanks!
