[magick-users] -draw compositing method
Anthony Thyssen
anthony at griffith.edu.au
Wed Aug 8 17:46:03 PDT 2007
"Cody P. Pace" on wrote...
| Hello,
|
| I am attempting to create an image with a gray background, a white =
| rounded
| rectangle, with a transparent interior. I'm using the following command:
|
| $ convert -size 236x160 xc:'rgb(102,102,102)' -stroke white \
| -fill 'rgba(0,0,0,255)' -draw 'roundRectangle 0,0 236,160 8,8' mask.png
| =20
| Unfortunately the transparent interior of the rectangle is composited =
| with
| with the opaque background. It seems like there should be a way to =
| change the
| composite method used by draw to just replace the background.
|
As you discovered, you can not draw transparency.
Nothing is drawn.
All you are doing is the equivelent of painting with water or a very
clear varnish.
What you really want to do is 'cutout' or 'sponge off' the old paint.
and that means you want to do two steps. paint the backgorund,
cutout the shape, and paint the border.
For example of cutting out a shape see Alpha Compositing
and the Dst_Out Composition method.
http://www.imagemagick.org/Usage/compose/#dstout
However there is a simplier method, for your situation, as you
are cutting out a shape from a plain solid color image.
Draw the 'cutout' shape, invert the transparency and color.
You can then overlay your border...
convert -size 236x160 xc:none -draw 'roundRectangle 0,0 235,159 8,8' \
-channel A -negate +channel A \
-fill 'rgb(102,102,102)' -colorize 100% \
-stroke white -fill none -draw 'roundRectangle 0,0 235,159 8,8' \
mask.png
NOTE:
* "none" or "transparent" is equivelent to rgba(0,0,0,255)
* The coordinates go from 0 to width-1 so subtract one from the
bottom and right edges of the rectangle.
A simular example is...
http://www.imagemagick.org/Usage/thumbnails/#rounded_border
Anthony Thyssen ( System Programmer ) <A.Thyssen at griffith.edu.au>
-----------------------------------------------------------------------------
Hi! I'm a shareware signature! Send $5 if you use me, send $10 for manual!
-----------------------------------------------------------------------------
Anthony's Home is his Castle http://www.cit.gu.edu.au/~anthony/
More information about the Magick-users
mailing list