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