More flexible file column?

The file column plug-in is great, but there is a problem with it. Well,
two… But the other is well documented now. :^)

Consider a time when you’ve created a CMS for a client and it’s been in
use for over a year. Say 1500+ images have been uploaded so far. Now the
client comes back with a simple request… ‘Can you change the thumbnail
size to 80/90, rather than 70/70? It shouldn’t take you more than half a
day…’
‘No problem!’ you say, ‘I’ll just change the CSS here, and the article
model here and… Oh.’ Broken images all over the place. No images at
all if you use Firefox.

It wasn’t quite 1500 images, but I ended up writing a script to
systematically go through each image in the database and resize it to
order… File column helpfully handles removing the old sizes for you.

This is all a but un-rails-like though. I’d expect the plugin to
automatically realise that the resized image is missing and create it on
the fly. It has all the tools and data to do so, and the perfomance hit
will only be felt once, by the first user who encounters the image. I’d
take that to be an acceptable compromise.

I have, in fact, written such code quite successfully in PHP. However,
I’m new to Ruby and not completely comfortable with it yet. Has anyone
done it themselves? If not, has anyone looked into the File Column code
enough to give me a few pointers? Obviously if I get it working I’ll
release it back to the Rails community…

Or does anyone think I’ve gone mad and should stick to scripts? ;^)

I thought file column made this sort of thing really easy.

|file_column :image, :magick => { :geometry => “800x600>” }

see: http://wiki.rubyonrails.org/rails/pages/HowToUseFileColumn
|

2006/6/1, DJ Tequila [email protected]:

I have, in fact, written such code quite successfully in PHP. However,
I’m new to Ruby and not completely comfortable with it yet. Has anyone
done it themselves? If not, has anyone looked into the File Column code
enough to give me a few pointers? Obviously if I get it working I’ll
release it back to the Rails community…

Or does anyone think I’ve gone mad and should stick to scripts? ;^)

this is how i did it (all images were jpgs):

lib/image_resize.rb:

require “action_controller/test_process”

Image.find_all.each do |i|
i.path=ActionController::TestUploadedFile.new(i.path, “image/jpeg”)
i.save
end

start:

script/runner “load(‘image_resize.rb’)”

–robert

This is all a but un-rails-like though. I’d expect the plugin to
automatically realise that the resized image is missing and create it on
the fly. It has all the tools and data to do so, and the perfomance hit
will only be felt once, by the first user who encounters the image. I’d
take that to be an acceptable compromise.

I’m building something with file_column right now and I think this is a
great idea. I have to admit at first I thought you were just asking for
more features. I listened to Sebastian speak at Canada on Rails and
everyone was asking him ‘can you make it do this? How about this? What
about this?’

The Rails rationale was to do what was right for most of the people most
of the time, and I think this fits. Unfortunately I have not the
technical know-how to help out with it yet, but let me know how it goes.

  1. modify the model to support a new thumbnail size

Attachment.find(:all).each do |a|
a.asset = File.open(a.asset) #opens each file_column based asset
a.save #rebuilds and saves - huzzah
end

from our friends at caboose - reference :
http://blog.caboo.se/articles/2006/01/09/file_column-magick-and-versions

-raja

Raja Bhatia, FiveLimes, Inc.
http//fivelimes.com

On 6/1/06, DJ Tequila [email protected] wrote:

all if you use Firefox.
This is why image transformations should be made in the view, not in
the model. the model should hold the canonical image, and the view
should create derivative images.>

I have, in fact, written such code quite successfully in PHP. However,
I’m new to Ruby and not completely comfortable with it yet. Has anyone
done it themselves? If not, has anyone looked into the File Column code
enough to give me a few pointers? Obviously if I get it working I’ll
release it back to the Rails community…

Check out my branch at http://svn.kylemaxwell.com/file_column/. It
implements view-side image transformations. You’ll have to look
through the source, particualarly magick_file_column.rb, since I
haven’t kept up the docs.

I’m open to the idea of forking file_column, as I am actively
developing my branch. I used to work closely with Sebastian on
file_column development. This appears stalled, as a point release
hasn’t happened in several months.


Kyle M.
Chief Technologist
E Factor Media // FN Interactive
[email protected]
1-866-263-3261

It wasn’t quite 1500 images, but I ended up writing a script to
systematically go through each image in the database and resize it to
order… File column helpfully handles removing the old sizes for you.

Acts as attachment supports multiple thumbnails for a single image. I
usually store the original image plus any smaller versions I may need.
I’ve changed thumbnail sizes several times during the development of
my current client project. I just loop through all uploaded images
and re-process everything in script/console.

If you’re doing this kind of thing often, maybe you need a different
solution?