possible bug in -flatten

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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug in -flatten

Post by fmw42 »

Hello, I was trying to answer a question on the forum at viewtopic.php?f=1&t=11856&p=38644#p38644 which in my solution involved the use of -flatten.

This did not work:
convert bg.JPG \
\( 01.JPG bg.JPG -compose change_mask -composite \) \
\( 02.JPG bg.JPG -compose change_mask -composite \) \
\( 03.JPG bg.JPG -compose change_mask -composite \) \
-flatten 123bg.png

But this did by adding -compose over
convert bg.JPG \
\( 01.JPG bg.JPG -compose change_mask -composite \) \
\( 02.JPG bg.JPG -compose change_mask -composite \) \
\( 03.JPG bg.JPG -compose change_mask -composite \) \
-compose over -flatten 123bg.png

The original images are at: http://www.boulder.swri.edu/~emma/work/misc/index.html


I was under the impression that the default for -compose was "over". But I am not sure that carries over to -layers composite of which -flatten is a member.

Is this a bug, or is there a different default -compose for -layers composite and thus for -flatten?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug in -flatten

Post by magick »

The compose attribute is associated with the image so when you set it inside parenthesis, it retains its value outside the parenthesis.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug in -flatten

Post by fmw42 »

OK. Thanks. I did not appreciate that fact that settings like -compose (as opposed to -set) carried outside the parens.

However, Anthony says you are working on it. So I assume the change will fix the issue that the following does not currently work by adding -respect-parenthesis, assuming that I have specified it correctly.

convert -respect-parenthesis bg.JPG \
\( 01.JPG bg.JPG -compose change_mask -composite \) \
\( 02.JPG bg.JPG -compose change_mask -composite \) \
\( 03.JPG bg.JPG -compose change_mask -composite \) \
-flatten 123bg.png
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug in -flatten

Post by magick »

ImageMagick maintains two structures, ImageInfo, and Image. The ImageInfo structure is stacked so when you exit parenthesis its memory is erased. However, images retain their memory inside and outside of parenthesis, such as the -compose operator. To fix the problem we would need to stack image attributes and we most likely could not do this before ImageMagick 7.0. Run it past Anthony and see what he says...
Post Reply