Forum: Ruby on Rails File_column : how can I resize/convert/whatever an image acc

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
6123164d2c35622a80b62d3ddaf5e86f?d=identicon&s=25 Dominique Rose-Rosette (Guest)
on 2006-01-11 15:42
(Received via mailing list)
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
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>" }

def resize_image
  # stuff that processes the image with the form-provided values
[:resize_dimension] (can be "w" (width) or "h" (height) ) and
so as to obtain the equivalent of "convert -resize '250x' stuff.jpg" or
"convert -resize 'x100' stuff.jpg"


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?


Dominique Rose-Rosette
This topic is locked and can not be replied to.