用户:
BelugaXiao查看:0 回复:0 评论:0 创建时间:2021-08-18T19:33:32
【作品展示】

【作品介绍】
laj
【作品源代码】
import os
from PIL import Image
import matplotlib.pyplot as plt
myDir = ("BCM")
files = os.listdir(myDir)
print(files)
# 常见的图片类型
images_ext = [".jpg", ".png", ".bmp", ".jpeg", ".gif"]
images = []
for file in files:
name, ext = os.path.splitext(file)
if ext in images_ext and 'bcm' in name:
img = Image.open(myDir+os.sep+file)
_img = img.resize((300, 300))
images.append(_img)
# print(images)
style = [[1, 0, 0, 0, 1],
[0, 1, 0, 1, 0],
[0, 0, 1, 0, 0],
[0, 1, 0, 1, 0],
[1, 0, 0, 0, 1]]
col = 5
row = 5
board = Image.new("RGBA", (300*col, 300*row))
for i in range(row):
for j in range(col):
if style[i][j] == 1:
index = j+col*i
board.paste(images[index % len(images)], (j*300, i*300))
plt.imshow(board)
plt.show()
board.save("heart.png")
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn