並不是所有的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