Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Reading Images via RMagick until Ruby killed
Guido Holz
1/30/2008 12:27:00 PM
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!
--
Posted via
http://www.ruby-...
.
2 Answers
Tim Hunter
1/30/2008 1:04:00 PM
0
Guido Holz wrote:
> 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&for...
Also, if you're using RMagick 2:
http://rmagick.ruby...
rma....
--
RMagick:
http://rmagick.ruby...
RMagick 2:
http://rmagick.ruby...
rma...
Guido Holz
1/30/2008 2:01:00 PM
0
Thanks! that was the reason :-)
cheers guido
Tim Hunter 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&for...
>
> Also, if you're using RMagick 2:
>
http://rmagick.rubyforge.org/rma...
.
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Reading Images via RMagick until Ruby killed
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password