Image conversion w/ file column


#1

hey

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 = ImageList.new(imgpath)
imgpath = imgpath.sub(/(jpg)$/, ‘png’)
img.write(imgpath)
end
end

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?

spe.