Patrick Aljord
2006-Jul-26 00:10 UTC
[Rails] webrick slows and crashes on thumbnail creation
ok here is my view code: <% for img in ary %> <%= resize_image img.name %> # img.name= /homa/joe/pictureimg.jpg <% end %> here is my resize_image code in application_helper: def resize_image(imgfile) pic = Magick::Image.read(imgfile).first thumb = pic.crop_resized(maxwidth, maxheight, gravity=Magick::CenterGravity) thumb.write(imgfile+''thumb'') end What happens: When "ary" contains 50 images to resize, it goes fast on the first 4 images then the whole thing slows down and and the ruby proccess occupies like 50% of CPU and 70% of memory and then after 15 pics webrick crashes complaning about how the disk might be full although it`s not. I think this is because it trys to create all thumbnails at the same time which needs too much cpu and ram. So my question is: is there any way to make the <% for img in ary %> loop wait for the current image to be resized before starting the resize of the next one? thanx in advance Pat -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060726/5297f980/attachment.html
Possibly Parallel Threads
- file_column Cropping -> image offset information
- rmagick working in console but not in my app
- Clusteranalysis Chi-square test and SingleLinkage
- File_column : how can I resize/convert/whatever an image according to form-submitted values?
- Borland C++ Builder TForm->Show() problem