Reading Images via RMagick until Ruby killed

G

Guido Holz

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... ;-)

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!
 
T

Tim Hunter

Guido said:
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... ;-)

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!

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top