mrz*_*gle 1 python imagemagick dropshadow wand
有没有人尝试用python魔杖创建dropshadow?我浏览了此文档,找不到dropshadow属性。
http://docs.wand-py.org/en/0.4.1/wand/drawing.html
根据imagemagick的说法,可以通过以下操作进行:http : //www.imagemagick.org/Usage/fonts/
convert -size 320x100 xc:lightblue -font Candice -pointsize 72 \
-fill black -draw "text 28,68 'Anthony'" \
-fill white -draw "text 25,65 'Anthony'" \
font_shadow.jpg
Run Code Online (Sandbox Code Playgroud)
我该如何在python中适应呢?
有没有人尝试用python魔杖创建dropshadow?
搜索wand标签时有一些技巧和示例。
我浏览了此文档,找不到dropshadow属性。
您不会看到属性,因为下拉阴影在矢量绘图上下文中是荒谬的。(至少我认为)
这是创建文本阴影的一种方法。
from wand.color import Color
from wand.compat import nested
from wand.drawing import Drawing
from wand.image import Image
dimensions = {'width': 450,
'height': 100}
with nested(Image(background=Color('skyblue'), **dimensions),
Image(background=Color('transparent'), **dimensions)) as (bg, shadow):
# Draw the drop shadow
with Drawing() as ctx:
ctx.fill_color = Color('rgba(3, 3, 3, 0.6)')
ctx.font_size = 64
ctx.text(50, 75, 'Hello Wand!')
ctx(shadow)
# Apply filter
shadow.gaussian_blur(4, 2)
# Draw text
with Drawing() as ctx:
ctx.fill_color = Color('firebrick')
ctx.font_size = 64
ctx.text(48, 73, 'Hello Wand!')
ctx(shadow)
bg.composite(shadow, 0, 0)
bg.save(filename='/tmp/out.png')
Run Code Online (Sandbox Code Playgroud)
编辑这是与“用法”示例匹配的另一个示例。
from wand.color import Color
from wand.drawing import Drawing
from wand.image import Image
# -size 320x100 xc:lightblue
with Image(width=320, height=100, background=Color('lightblue')) as image:
with Drawing() as draw:
# -font Candice
draw.font = 'Candice'
# -pointsize 72
draw.font_size = 72.0
draw.push()
# -fill black
draw.fill_color = Color('black')
# -draw "text 28,68 'Anthony'"
draw.text(28, 68, 'Anthony')
draw.pop()
draw.push()
# -fill white
draw.fill_color = Color('white')
# -draw "text 25,65 'Anthony'"
draw.text(25, 65, 'Anthony')
draw.pop()
draw(image)
# font_shadow.jpg
image.save(filename='font_shadow.jpg')
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1046 次 |
最近记录: |