pip install Pillow
pypi地址: https://pypi.org/project/Pillow/
font = ImageFont.truetype("simsun.ttc", fontSize,encoding="utf-8")
fill=(106,106,106)
i,j = 0,0 while True: x,y = i*step,i*step if y < height : x = 0 if y > height : x = j*step j = j + 1 y = height - 10 #print(i,"xy :",x,y) draw_text(img,(x,y),fill,mask,rotated_mask) if (x + step > width ) and (y + step > height ) : break i = i + 1
img.save(dstFile,optimize=True, quality=100)
pool = Pool(processes=8) # set the processes max number for root, dirs, files in os.walk(srcDir): for name in files: srcFile = os.path.join(root, name) dstFile = os.path.join(dstDir, name) print("%s => %s" % (srcFile,dstFile)) # add_watermark(srcFile,dstFile,fontSize,myText,angle,fill,step) result = pool.apply_async(add_watermark,(srcFile,dstFile,fontSize,myText,angle,fill,step)) pool.close() pool.join()
執行效果演示視訊獲取途徑: