Page 1 of 1

-composite loses next to top img list, when top transparent

Posted: 2012-11-07T23:44:20-07:00
by vincentb1
Hello,

Sorry for my question may be naive... Here is a command line:

Code: Select all

convert  -size 960x960 -fill white xc:transparent -draw 'rectangle 480,384,960,960' -draw 'rectangle 0,0,320,820' -strokewidth 48 -stroke 'rgb(85,131,157)' -draw 'arc 0,48 320,96 5,175' -draw 'arc 0,168,320,216 5,175' -draw 'arc 0,288,320,336 5,175' -strokewidth 0 \( -size 576x480 gradient:red-blue -rotate 90 -background transparent -extent 960x960-320 \) -composite -resize 96x96 jpicedt1.ico
The resulting image is:

Image

which is what I expected.

Now I add a transparent image

Code: Select all

\( -size 960x960 xc:transparent \) 
to the list of images before doing -composite:

Code: Select all

convert  -size 960x960 -fill white xc:transparent -draw 'rectangle 480,384,960,960' -draw 'rectangle 0,0,320,820' -strokewidth 48 -stroke 'rgb(85,131,157)' -draw 'arc 0,48 320,96 5,175' -draw 'arc 0,168,320,216 5,175' -draw 'arc 0,288,320,336 5,175' -strokewidth 0 \( -size 576x480 gradient:red-blue -rotate 90 -background transparent -extent 960x960-320 \) \( -size 960x960 xc:transparent \) -composite -resize 96x96 jpicedt2.ico
The resulting image is:

Image

I am a bit puzzled, the second image with the red-blue gradient is lost just because I am adding a transparent image on top of the list. I would have expected that adding a transparent on the top would have in no way changed the result.

Any help is welcome, I am at the end of my wits :( ...

PS: I am using

Code: Select all

convert -version
Version: ImageMagick 6.6.1-0 2010-04-02 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP 

Re: -composite loses next to top img list, when top transpar

Posted: 2012-11-08T05:13:52-07:00
by vincentb1
I forgot to say that I am on MSWindowXP.

Re: -composite loses next to top img list, when top transpar

Posted: 2012-11-08T05:25:04-07:00
by vincentb1
One more thing: I have just tried the same experiment with the latest binary version, aka:

Code: Select all

convert -version
Version: ImageMagick 6.8.0-4 2012-10-30 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP
and I am into the same issue

I launched the command from an MSYS bash shell, but just I tried from under cmd.exe shell, and it has the same effect.

Re: -composite loses next to top img list, when top transpar

Posted: 2012-11-08T07:53:52-07:00
by snibgo
If we lay out the command with line-breaks at logical places (Windows cmd syntax) ...

convert ^
-size 960x960 -fill white xc:transparent ^
-draw "rectangle 480,384,960,960" ^
-draw "rectangle 0,0,320,820" ^
-strokewidth 48 -stroke rgb(85,131,157) ^
-draw "arc 0,48 320,96 5,175" ^
-draw "arc 0,168,320,216 5,175" ^
-draw "arc 0,288,320,336 5,175" ^
-strokewidth 0 ^
( -size 576x480 gradient:red-blue -rotate 90 -background transparent -extent 960x960-320 ) ^
( -size 960x960 xc:transparent ) ^
-composite ^
-resize 96x96 ^
jpicedt2.ico

... we clearly see you are trying to apply "-composite" to three images. But it doesn't work that way. (The 3rd image is used as a mask, which isn't what you want.) Treat "-composite" as a binary operator, and we might get what you want:

convert ^
-size 960x960 -fill white xc:transparent ^
-draw "rectangle 480,384,960,960" ^
-draw "rectangle 0,0,320,820" ^
-strokewidth 48 -stroke rgb(85,131,157) ^
-draw "arc 0,48 320,96 5,175" ^
-draw "arc 0,168,320,216 5,175" ^
-draw "arc 0,288,320,336 5,175" ^
-strokewidth 0 ^
( -size 576x480 gradient:red-blue -rotate 90 -background transparent -extent 960x960-320 ) ^
-composite ^
( -size 960x960 xc:transparent ) ^
-composite ^
-resize 96x96 ^
jpicedt2.ico

Re: -composite loses next to top img list, when top transpar

Posted: 2012-11-08T12:16:50-07:00
by vincentb1
Thank you very much, I should have read the documentation with more attention :?

Re: -composite loses next to top img list, when top transpar

Posted: 2012-12-17T16:46:57-07:00
by anthony
Alternately replace composite with the appropriate 'layer' operator, like -flatten.

See Layering Images
http://www.imagemagick.org/Usage/layers/#layers

Note layers use virtual canvas offsets for positions rather than geometry offsets which is used by the lower level composite operator.