rmagick crash?

Discussion in 'Ruby' started by Roeland Moors, Aug 29, 2004.

  1. 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


    --
    Roeland
    Roeland Moors, Aug 29, 2004
    #1
    1. Advertising

  2. Roeland Moors

    Tim Hunter Guest

    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 :)
    >
    > 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.
    Tim Hunter, Aug 29, 2004
    #2
    1. Advertising

  3. 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 :)
    > >
    > > 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 :)

    Thanks

    Roeland
    Roeland Moors, Aug 30, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tim Hunter

    [ANN] RMagick moves to RubyForge

    Tim Hunter, Jul 27, 2003, in forum: Ruby
    Replies:
    0
    Views:
    102
    Tim Hunter
    Jul 27, 2003
  2. Robert Feldt

    RMagick is nice... bar chart

    Robert Feldt, Aug 22, 2003, in forum: Ruby
    Replies:
    2
    Views:
    114
    Robert Feldt
    Aug 22, 2003
  3. Tim Hunter

    ANN: RMagick 1.4.0 released

    Tim Hunter, Feb 15, 2004, in forum: Ruby
    Replies:
    0
    Views:
    88
    Tim Hunter
    Feb 15, 2004
  4. De Railed

    RB + RMagick = cd Crash...

    De Railed, Mar 26, 2006, in forum: Ruby
    Replies:
    4
    Views:
    136
    Kaspar Schiess
    Mar 28, 2006
  5. Pito Salas
    Replies:
    1
    Views:
    138
    Tim Hunter
    Apr 24, 2009
Loading...

Share This Page