rmagick crash?

R

Roeland Moors

I use rmagick to transform an image.
This works nice for 1 or a couple or images, but when I do more
images I have problems.

After a couple of images my program just stops with the output
'killed'. No error message, nothing.

Then I updated to the latest version of rmagick en tried again.
It did more images, but then my pc completely crashed!
(I'm not using windows :)

What could cause these problems?
Am I doing something stupid?

Here are pieces of the code:

# convert a lot of pictures
@photolist.each do |photo|
photo.convert()
end

class Photo
def convert(preview = false)
img = Magick::ImageList.new(@name)

width = $format['width']
height = $format['height']
top = $format['border_top']
left = $format['border_left']

if preview
top = top / (height/200)
left = left / (width/300)
width = 300
height = 200
end

# rotate to landscape
img.rotate!(90) if img.rows > img.columns

geometry = "#{width}x#{height}"

# resize current image
img.change_geometry!(geometry) do |cols, rows|
if preview
img.scale!(cols, rows)
#img.thumbnail!(cols, rows)
else
img.resize!(cols, rows)
end
end

# create an empty image
dest = Magick::ImageList.new
dest.new_image(width + 2*left, height + 2*top) do
self.background_color = 'black'
end

# create text on photo
text = Magick::Draw.new
text.gravity = Magick::NorthWestGravity
text.rotation = 90

# date
ps = 2.5 * width /100
text.pointsize = ps
pos = width+left-ps
text.annotate(dest, ps, height, pos, top, @date) do
self.fill = 'white'
end
ps = 6 * width /100
text.pointsize = ps
pos = pos-ps
text.annotate(dest, ps, height, pos, top, @description) do
self.fill = 'white'
end

# merge images
dest = dest.composite(img, left, top, Magick::InCompositeOp)

dest.write($filename)
$filename
end

end
 
T

Tim Hunter

Roeland said:
I use rmagick to transform an image.
This works nice for 1 or a couple or images, but when I do more
images I have problems.

After a couple of images my program just stops with the output
'killed'. No error message, nothing.

Then I updated to the latest version of rmagick en tried again.
It did more images, but then my pc completely crashed!
(I'm not using windows :)

What could cause these problems?
Am I doing something stupid?

Sorry you're having trouble with RMagick.

I'm guessing that you're running out of memory. For some reason GC is not
able to clean up the image objects you're no longer using.

If you send me the whole program I'll see what I can do.
 
R

Roeland Moors

Sorry you're having trouble with RMagick.

I'm guessing that you're running out of memory. For some reason GC is not
able to clean up the image objects you're no longer using.

If you send me the whole program I'll see what I can do.
You can get it from CVS here:
http://rubyforge.org/projects/photoprep/

After installing it, you can start it with 'photoprep *.jpg' or
somthing like that.
The program is not finished so I hope you can start it :)

Thanks

Roeland
 

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

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top