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?
possible bug in -flatten
Re: possible bug in -flatten
The compose attribute is associated with the image so when you set it inside parenthesis, it retains its value outside the parenthesis.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug in -flatten
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
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
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...