# File\_column : how can I resize/convert/whatever an image acc

**URL:** <https://www.ruby-forum.com/t/file-column-how-can-i-resize-convert-whatever-an-image-acc/52157>\
**Category:** Rails\
**Created:** [January 11, 2006, 3:42pm UTC](https://www.ruby-forum.com/t/file-column-how-can-i-resize-convert-whatever-an-image-acc/52157 "2006-01-11T15:42:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dominique\_Rose-Rose](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9c0ed/32.png) [@Dominique\_Rose-Rose](https://www.ruby-forum.com/u/Dominique_Rose-Rose)\
**Post date:** [January 11, 2006, 3:42pm UTC](https://www.ruby-forum.com/t/file-column-how-can-i-resize-convert-whatever-an-image-acc/52157/1 "2006-01-11T15:42:00Z")

</div>

Hi guys,

I want to have a file upload form which would allow the user to ask for  
certain transformations of the image before saving it - most  
importantly, to  
resize it.

Now, how can I make an instance of FileColumn enabled model process  
these  
imagemagick instructions?

My model looks looks somewhat like :

class Image \< ActiveRecord::Base

attr\_accessor :resize\_dimension, :resize\_to

before\_save :resize\_image

file\_column :path,  
:versions =\> { “thumbnail” =\> “100x100\>” }

private  
def resize\_image

# stuff that processes the image with the form-provided values

[:resize\_dimension] (can be “w” (width) or “h” (height) ) and  
[:resize\_to],  
so as to obtain the equivalent of “convert -resize ‘250x’ stuff.jpg” or  
“convert -resize ‘x100’ stuff.jpg”  
end

end

What should I put in that resize\_image callback function? Would a  
callback be  
the DRY way, to begin with?

Any tips, ideas, previous experiences, anyone?

TIA,

Dominique Rose-Rosette
