Rmagick crash?

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 :slight_smile:

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

路路路

--
Roeland

Roeland Moors wrote:

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 :slight_smile:

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.

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 :slight_smile:

Thanks

Roeland

路路路

On Mon, Aug 30, 2004 at 12:45:28AM +0900, Tim Hunter wrote:

Roeland Moors wrote:

> 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 :slight_smile:
>
> 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.