用户登录
用户注册

分享至

python给图片右上角加上红色的数字

  • 作者: 沈温柔阿
  • 来源: 51数据库
  • 2022-08-12
from PIL import Image,ImageDraw,ImageFont

def addNum(filePath):
    img = Image.open(filePath)
    size = img.size
    fontSize = size[1] / 4
    draw = ImageDraw.Draw(img)
   
    ttFont = ImageFont.truetype("/Library/Fonts/arial.ttf", fontSize)
    draw.text((size[0]-fontSize, 0), "3",(256,0,0), font=ttFont)
    del draw
    img.save('./result.jpg')
    img.show()

print addNum("image.jpg")

软件
前端设计
程序设计
Java相关