Page 1 of 1

possible bug in -flatten

Posted: 2008-08-14T12:26:18-07:00
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?

Re: possible bug in -flatten

Posted: 2008-08-14T17:35:32-07:00
by magick
The compose attribute is associated with the image so when you set it inside parenthesis, it retains its value outside the parenthesis.

Re: possible bug in -flatten

Posted: 2008-08-14T22:45:31-07:00
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

Re: possible bug in -flatten

Posted: 2008-08-15T06:07:18-07:00
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...