photo_exif_date_print.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:python-image-processing 作者: karaage0703 项目源码 文件源码
def put_date(file, date):
    base_img_cv2 = cv2.imread(file)

    base_img = Image.open(file).convert('RGBA')
    txt = Image.new('RGB', base_img.size, (0, 0, 0))
    draw = ImageDraw.Draw(txt)
    fnt = ImageFont.truetype('./Arial Black.ttf', size=(int)((base_img.size[0]+base_img.size[1])/100))

    textw, texth = draw.textsize(date, font=fnt)

    draw.text(((base_img.size[0]*0.95 - textw) , (base_img.size[1]*0.95 - texth)),
              date, font=fnt, fill=font_color)

    txt_array = np.array(txt)

    output_img = cv2.addWeighted(base_img_cv2, 1.0, txt_array, 1.0, 0)
    return output_img
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号