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 | DJ Tequila wrote:> 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? ;^) > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
2006/6/1, DJ Tequila <mail@djtequila.com>:> 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> _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
> 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. -- Posted via http://www.ruby-forum.com/.
1) modify the model to support a new thumbnail size 2) 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, Jason Pfeifer <jpfeifer@shaw.ca> wrote:> > 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. > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Have you tried it? Did it work? From what I''ve seen and experienced, all that does is make sure any FUTURE uploads save to the new size. Not ideal. Unless, of course, the functionality has simply failed on all my projects, but works on everyone else''s. I haven''t ruled that possibility out yet! ;^) No, I''ve already read the instructions and I did get excited, but after a little frustration I came to the conclusion that ''To *resize every uploaded image* to a maximum size of 640?480, you just have to declare...'' means ''To create 640*480 on every future upload, you just have to declare...'' ------------------------------ Message: 3 Date: Thu, 01 Jun 2006 09:03:35 -0600 From: Steven Hansen <runner@berkeley.edu> Subject: Re: [Rails] More flexible file column? To: rails@lists.rubyonrails.org Message-ID: <447F01C7.2050306@berkeley.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed 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
On 6/1/06, DJ Tequila <mail@djtequila.com> wrote:> 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.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.>> 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...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 Maxwell Chief Technologist E Factor Media // FN Interactive kyle@efactormedia.com 1-866-263-3261
No I haven''t tried it. I''ll give it a shot tonight and email the list if it works. I guess I shouldn''t have assumed that this was how this feature works. :-( -Steven DJ Tequila wrote:> Have you tried it? Did it work? From what I''ve seen and experienced, > all that does is make sure any FUTURE uploads save to the new size. > Not ideal. Unless, of course, the functionality has simply failed on > all my projects, but works on everyone else''s. I haven''t ruled that > possibility out yet! ;^) No, I''ve already read the instructions and I > did get excited, but after a little frustration I came to the > conclusion that ''To *resize every uploaded image* to a maximum size of > 640?480, you just have to declare...'' means ''To create 640*480 on > every future upload, you just have to declare...'' > ------------------------------ Message: 3 Date: Thu, 01 Jun 2006 > 09:03:35 -0600 From: Steven Hansen <runner@berkeley.edu> Subject: Re: > [Rails] More flexible file column? To: rails@lists.rubyonrails.org > Message-ID: <447F01C7.2050306@berkeley.edu> Content-Type: text/plain; > charset=ISO-8859-1; format=flowed 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 > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
> 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? http://www.infoq.com/articles/Agile-Asset-Management -- Rick Olson http://techno-weenie.net
Just wanted to say a big thank you to all the people who replied to this. There are some very useful scripts there (which I don''t understand yet, but if they work, bonus! They''re certainly more generic and terse than mine, although I was migrating from a different database, a different language and a flat directory structure at the same time!), and I''ll be sure to look at the file column branch. I can''t promise to understand it right now though. Maybe when I''ve made it through Pickaxe.