并不是所有的CLI方法都存在于与wand集成的C-API库中。但是,大多数行为方法都很简单(例如+swap
),并且您可以在应用程序认为合适时自由实施它们。
from wand.image import Image
from wand.color import Color
from wand.drawing import Drawing
from wand.compat import nested
with nested(Image(width=100, height=100, background=Color("transparent")),
Image(width=100, height=100, background=Color("transparent"))) as (text,
shadow):
with Drawing() as ctx:
ctx.stroke_color = Color("black")
ctx.fill_color = Color("white")
ctx.font_size = 48
ctx.text(text.width/2, text.height/2, 'A')
ctx(text)
with Drawing() as ctx:
ctx.fill_color = Color("navy")
ctx.font_size = 48
ctx.text(text.width/2, text.height/2, 'A')
ctx(shadow)
shadow.gaussian_blur(80, 3)
shadow.composite(text, -3, -3)
shadow.trim()
shadow.save(filename='shadow_a.png')
嘛,悲伤,但仍感谢。 – MCManuelLP