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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
vincentb1
Posts: 12
Joined: 2012-11-07T23:16:05-07:00
Authentication code: 67789

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

Post 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 
vincentb1
Posts: 12
Joined: 2012-11-07T23:16:05-07:00
Authentication code: 67789

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

Post by vincentb1 »

I forgot to say that I am on MSWindowXP.
vincentb1
Posts: 12
Joined: 2012-11-07T23:16:05-07:00
Authentication code: 67789

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

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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
snibgo's IM pages: im.snibgo.com
vincentb1
Posts: 12
Joined: 2012-11-07T23:16:05-07:00
Authentication code: 67789

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

Post by vincentb1 »

Thank you very much, I should have read the documentation with more attention :?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply