File_Column: Saving image dimentions in database


#1

I’ve been using file_column for a while and it’s the best thing since
sliced bread. But there’s one thing that it doesn’t do that seems like
it’d be a pretty useful feature.

For an app I’m working on I really need to know the dimensions of the
store image in my view (and in general it’s always good to have the
dimensions in your image_tag). Unfortunately file_column doesn’t store
that info in the database. I could use RMagick to get the dimensions
each time the image is show, but this seems like an expensive way to do
it. Also, the size will be different with each image, so using the
versions to set a specific size won’t work for me.

So has anyone else run into this problem? I’m thinking of hacking
file_column so that it saves the image size in another database field.
It doesn’t seem like this should be too hard to do, but I’m still a bit
of a ruby/rails nuby, so I’d appreciate any advice on the best approach
to do this.

Thanks.