import numpy
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
from numpy import fft
i1 = Image.open("d:/abc.jpg")
weigh = i1.size[0]
heigh = i1.size[1]
i2 = Image.new('RGB', (weigh, heigh), (255, 255, 255))
font = ImageFont.truetype("arial.ttf", 36)
font.size = 36
draw = ImageDraw.Draw(i2)
draw.text((0, 0), "Mark By Michaelssss", font=font, fill=(0, 0, 0))
i2 = i2.transpose(Image.ROTATE_180)
draw = ImageDraw.Draw(i2)
draw.text((0, 0), "Mark By Michaelssss", font=font, fill=(0, 0, 0))
arr1 = numpy.array(i1)
arr2 = numpy.array(i2)
final = numpy.uint8(fft.ifft2(arr2 * 40 + fft.fft2(arr1)))
Image.fromarray(final).show()
# Image.fromarray(numpy.uint8(arr2)).show()
Image.fromarray(numpy.uint8(fft.fft2(numpy.array(final)) - fft.fft2(arr1))).show()
这样就能添加一个盲水印,感谢开源让我不用学习如何手撕FFT哈哈哈哈哈哈