MagickAddImage() adds to inconsistant position

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
fisheggs

MagickAddImage() adds to inconsistant position

Post 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"
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: MagickAddImage() adds to inconsistant position

Post 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.
fisheggs

Re: MagickAddImage() adds to inconsistant position

Post by fisheggs »

Thank you.
Post Reply