Page 1 of 1

Combining with transparency

Posted: 2010-08-19T05:33:00-07:00
by adrinux
After much manual/example reading and experimentation I've constructed a string of commands that give the result I want:

Code: Select all

convert -size 994x300 xc:white -stroke '#bbbbbb' -strokewidth 5 -fill transparent -draw "roundrectangle 1,1 992,298 10,10" -gaussian 12,4 innershadow.png
convert -size 994x300 xc:'#302f2b' -fill white -draw "roundrectangle 3,3 990,296 10,10" +transparent '#302f2b' border.png
convert border.png innershadow.png -compose dst-atop -composite border-shadow.png
convert border-shadow.png -stroke '#7c000d' -strokewidth 3 -fill transparent -draw "roundrectangle 1,1 992,298 10,10" rounded-shadowed.png
Now I'm looking to combine these commands and failing at the first hurdle. So combining the first 3:

Code: Select all

convert -size 994x300 xc:'#302f2b' -fill white -draw "roundrectangle 3,3 990,296 10,10" +transparent '#302f2b' \( +clone xc:white -stroke '#bbbbbb' -strokewidth 5 -fill transparent -draw "roundrectangle 1,1 992,298 10,10" -gaussian 12,4 \) -compose dst-atop -composite result.png
Results in the white background and gaussian shadow effectively disappearing, leaving the centre of the image transparent instead of white. What do I need to do so that the src image is seen through the transparent area of destination when combining the commands?

Re: Combining with transparency

Posted: 2010-08-19T07:11:04-07:00
by adrinux
Half answering my own question, adding a +matte to the clone does the trick:

Code: Select all

convert -size 994x300 xc:'#302f2b' -fill white -draw "roundrectangle 3,3 990,296 10,10" +transparent '#302f2b' \( +clone +matte xc:white -stroke '#bbbbbb' -strokewidth 5 -fill transparent -draw "roundrectangle 1,1 992,298 10,10" -gaussian 12,4 \) -compose dst-atop -composite result.png
This disables the transparency added in the first part, so the clone doesn't show as transparent. I think :D

Now to add the rest of the commands...

Re: rounded corners with inner shadow

Posted: 2010-08-19T07:27:47-07:00
by adrinux
Here's the final result, since I found no examples of an inner shadow elsewhere. This has reduced dimensions compared to the above and a more obvious shadow, since it's just an example rather than what I actually need.

Code: Select all

convert -size 200x200 xc:'#302f2b' -fill white -draw "roundrectangle 3,3 196,196 10,10" +transparent '#302f2b' \( +clone +matte xc:white -stroke '#333333' -strokewidth 5 -fill transparent -draw "roundrectangle 1,1 198,198 10,10" -gaussian 12,4 \) -compose dst-atop -composite -stroke '#7c000d' -strokewidth 3 -fill transparent -draw "roundrectangle 1,1 198,198 10,10" result.png