Page 1 of 1

MagickAddImage() adds to inconsistant position

Posted: 2007-07-15T04:24:59-07:00
by fisheggs
The doc for MagickAddImage() says it 'adds the specified images at the current image location.'

I have two problems
  • If I iterate to the required position MagickAddImage() adds the images to the end of the list rather than in the middle where I want it.
  • If I explicitly set the 'current image location' with MagickSetIteratorIndex(), MagickAddImage() inserts the images before the 'current image location'. I would have expected it to add them after.
I can live with the 2nd one if that is how it's supposed to work, but the 1st seems like a bug.

The relevant code seems to be at lines 443 and 453 of wand/magick-image.c

What I was doing:-

Code: Select all

    # without declarations or return value checks
    rgb = NewMagickWand()
    MagickSetSize(rgb, 64, 64)
    MagickSetLastIterator(rgb);     MagickReadImage(rgb, 'xc:red')
    MagickSetLastIterator(rgb);     MagickReadImage(rgb, 'xc:green')
    MagickSetLastIterator(rgb);     MagickReadImage(rgb, 'xc:blue')

    rgb2 = CloneMagickWand(rgb)     # copy for 2nd test

    cmy = NewMagickWand()
    MagickSetSize(cmy, 64, 64)
    MagickSetLastIterator(cmy);     MagickReadImage(cmy, 'xc:cyan')
    MagickSetLastIterator(cmy);     MagickReadImage(cmy, 'xc:magenta')
    MagickSetLastIterator(cmy);     MagickReadImage(cmy, 'xc:yellow')

    # test 1 -- iterating to position
    MagickResetIterator(rgb)
    MagickNextImage(rgb)        # red is current
    MagickNextImage(rgb)        # green is current

    MagickAddImage(rgb, cmy)               # I expect "r g C M Y b"
    result = MagickAppendImages(rgb, 0)
    MagickWriteImage(result, 'X:')         # I get    "r g b C M Y"

    # test 2 --  explicitly set position
    MagickSetIteratorIndex(rgb2, 1)         # green is current

    MagickAddImage(rgb2, cmy)               # I expect "r g C M Y b"
    result = MagickAppendImages(rgb2, 0)
    MagickWriteImage(result, 'X:')          # I get    "r C M Y g b"

Re: MagickAddImage() adds to inconsistant position

Posted: 2007-07-16T17:53:15-07:00
by magick
We have a patch for the problem you reported in ImageMagick 6.3.5-2 Beta available sometime tomorrow. Thanks for bringing this problem to our attention.

Re: MagickAddImage() adds to inconsistant position

Posted: 2007-07-16T19:02:59-07:00
by fisheggs
Thank you.