核心功能 给照片加水印
给照片添加水印的代码多种多样,下面这种的或许是最为简单的形式:
代码实现
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
def watermark_Image(img_path,output_path, text, pos):
img = Image.open(img_path)
drawing = ImageDraw.Draw(img)
black = (10, 5, 12)
drawing.text(pos, text, fill=black)
img.show()
img.save(output_path)
img = '2.png'
watermark_Image(img, 'watermarked_2.jpg','水印文字', pos=(10, 10))