为图像绘制菱形边框

时间:2016-10-16 17:19:21

标签: python

我需要为图像添加边框,但是在菱形形状中,我可以使用以下代码轻松添加矩形边框,但需要一些想法如何使用python魔杖或PIL绘制菱形。我可以翻转一个矩形,但文字应该适合菱形。另一个想法是绘制四条直线并连接它们。也许你们中的一些人已经以更好的方式解决了这个问题寻找提示如何有效地做到这一点。

理想的形状:

enter image description here

from wand.color import Color
from wand.drawing import Drawing
from wand.image import Image
from wand.display import display
from moviepy.editor import *

# -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.border(Color('red'), 3,3)
    image.save(filename='font_shadow.jpg')
    #display(image) 

0 个答案:

没有答案