今天刷到一个很酷的壁纸,准备动手,准备动手
废话不多说上代码
首先
pip install pillow
如果下载速度太慢换阿里源(百试不爽
pip install pillow -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
from PIL import Image, ImageDraw
# 把原图跟本代码放在同一目录下
image = Image.open('原图') # 括号里填图片名称+图片格式
radius = 10 # 波点半径
offset = 3 # 波点间距
output_image = Image.new("RGB", image.size)
draw = ImageDraw.Draw(output_image)
# 绘制
for x in range(0, image.width, radius * 2 + offset):
for y in range(0, image.height, radius * 2 + offset):
box = (x, y, x + radius * 2, y + radius * 2)
region = image.crop(box)
stat = ImageStat.Stat(region)
average_c