Reading Images via RMagick until Ruby killed

Hey mates,

I´m a newbie to Ruby and Rails. But I´m a programer since few years. So
my problem is, that I will try to read a lot of photos with RMagick.

require ‘rubygems’ # if installed via Gems
require ‘RMagick’
include Magick

exit 1 if ARGV.length != 1

files = Dir.new(ARGV[0])

exit 1 unless files

files.each do |file|
next unless file =~ %r{.jpg$}i

puts ARGV[0]+file
img = Image.read(ARGV[0]+file).first
img_orient = img.auto_orient # turn a copy
img_gallery = img_orient.resize_to_fit(1024,1024) # scales a copy down
end

Don´t be scared about my code… :wink:

Ok… normaly I think, I can read every image - given from the directoy
in ARGV[0]. In C or C++ I know, that in every cicle of the loop img,
img_orient, img_gallery will be overwritten. But after 12-15 image
(appr. 2.5 MB => 30-40 MB ) the memory-allocation is incredible high…
so why?!?

I hope, that anyone can help me.

thanks!

Guido Holz wrote:

img_gallery = img_orient.resize_to_fit(1024,1024) # scales a copy down
I hope, that anyone can help me.

thanks!

http://rubyforge.org/forum/forum.php?thread_id=1374&forum_id=1618

Also, if you’re using RMagick 2:
http://rmagick.rubyforge.org/rmagick2.html.

Thanks! that was the reason :slight_smile:

cheers guido

Tim H. wrote:

Guido Holz wrote:

img_gallery = img_orient.resize_to_fit(1024,1024) # scales a copy down
I hope, that anyone can help me.

thanks!

http://rubyforge.org/forum/forum.php?thread_id=1374&forum_id=1618

Also, if you’re using RMagick 2:
http://rmagick.rubyforge.org/rmagick2.html.