Forum: Ruby on Rails image conversion w/ file column

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.
spiceee (Guest)
on 2005-11-16 03:18
(Received via mailing list)

I'm trying to find a way to convert images that were uploaded using
file_column *before* file_column generates a thumb and copies them to
the final dir - this because 50x50 is pretty small and png would be a
much better format (in smaller dimensions) than jpg or gif.

This is what i have in my model (using rmagick for the conversion):

file_column :image, :magick => {:versions => { "thumb" => "50x50" }}
  before_validation :convert_to_png

  def convert_to_png
    if self.image_just_uploaded?
      imgpath = self.image()
      img =
      imgpath = imgpath.sub(/(jpg)$/, 'png')

Which manages to save a png version of the original image in the final
dir but the thumb is still being derived from the jpg.

Any clues?

This topic is locked and can not be replied to.