def drawText_BKG(cimg, txt, posxy, fz, bkglen):
ttFont0 = ImageFont.truetype(fontfile, fz)
im = Image.fromarray(cimg, 'RGB')
drawable = ImageDraw.Draw(im)
drawable.polygon(((posxy[0], posxy[1]), \
(posxy[0]+bkglen, posxy[1]), \
(posxy[0]+bkglen, posxy[1]+fz), \
(posxy[0], posxy[1]+fz)), fill=(255, 255, 255))
drawable.text ((posxy[0], posxy[1]), txt, fill=(0, 0, 255), font=ttFont0)
npimg = np.asarray(im)
return npimg
评论列表
文章目录