Python-图片添加中文 发表于 2018-09-01 | 分类于 Python | | Python 图片添加中文文字。 123456789101112img_PIL = Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))font = ImageFont.truetype(fontLib, 40)fillColor = (255, 0, 255)position = (int((videoWidth - 65) * widthScale), 40)str = "实时人数:%d" %(lastPeopleCount)if not isinstance(str, unicode): str = str.decode('utf8') draw = ImageDraw.Draw(img_PIL)draw.text(position, str, font = font, fill = fillColor)imgNew = cv2.cvtColor(np.asarray(img_PIL), cv2.COLOR_RGB2BGR)img[:] = imgNew[:]