-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path520.py
100 lines (94 loc) · 3.62 KB
/
520.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
__author__ = 'thinkalonely'
__mtime__ = '2018/5/21'
# code is far away from bugs with the god animal protecting
I love animals. They taste delicious.
┏┓ ┏┓
┏┛┻━━━┛┻┓
┃ ☃ ┃
┃ ┳┛ ┗┳ ┃
┃ ┻ ┃
┗━┓ ┏━┛
┃ ┗━━━┓
┃ 神兽保佑 ┣┓
┃ 永无BUG! ┏┛
┗┓┓┏━┳┓┏┛
┃┫┫ ┃┫┫
┗┻┛ ┗┻┛
"""
from PIL import Image
import random
mw = 100
ms = 20
toImage = Image.new('RGB', (2000, 2000))
names = []
with open("C:/Users/hoo/desktop/pic.txt", "r") as f:
for line in f:
line = line.strip()
names.append(line)
for y in range(1, 21):
if y in [1, 7]:
for x in range(1, 21):
try:
fromImage = Image.open("C:/Users/hoo/Pictures/%s" % random.sample(names, 1)[0])
fromImage = fromImage.resize((100, 100), Image.ANTIALIAS)
if x in list(range(2, 7)) or x in list(range(9, 14)) or x in list(range(16, 20)):
toImage.paste(fromImage, ((x - 1) * mw, y * mw))
except IOError:
pass
elif y in [2, 3]:
for x in range(1, 21):
try:
fromImage = Image.open("C:/Users/hoo/Pictures/%s" % random.sample(names, 1)[0])
fromImage = fromImage.resize((100, 100), Image.ANTIALIAS)
if x in [2, 13, 16, 19]:
toImage.paste(fromImage, ((x - 1) * mw, y * mw))
except IOError:
pass
elif y == 4:
for x in range(1, 21):
try:
fromImage = Image.open("C:/Users/hoo/Pictures/%s" % random.sample(names, 1)[0])
fromImage = fromImage.resize((100, 100), Image.ANTIALIAS)
if x not in [1, 7, 8, 14, 15, 17, 18, 20]:
toImage.paste(fromImage, ((x - 1) * mw, y * mw))
except IOError:
pass
elif y in [5, 6]:
for x in range(1, 21):
try:
fromImage = Image.open("C:/Users/hoo/Pictures/%s" % random.sample(names, 1)[0])
fromImage = fromImage.resize((100, 100), Image.ANTIALIAS)
if x in [6, 9, 16, 19]:
toImage.paste(fromImage, ((x - 1) * mw, y * mw))
except IOError:
pass
for x in range(1, 21):
if x in [2, 4, 6, 11, 17]:
for y in range(13, 18):
try:
fromImage = Image.open("C:/Users/hoo/Pictures/%s" % random.sample(names, 1)[0])
fromImage = fromImage.resize((100, 100), Image.ANTIALIAS)
toImage.paste(fromImage, ((x - 1) * mw, y * mw))
except IOError:
pass
if x in [3, 5, 12, 18]:
y = 13
try:
fromImage = Image.open("C:/Users/hoo/Pictures/%s" % random.sample(names, 1)[0])
fromImage = fromImage.resize((100, 100), Image.ANTIALIAS)
toImage.paste(fromImage, ((x - 1) * mw, y * mw))
except IOError:
pass
if x in [10, 16]:
for y in (13, 17):
try:
fromImage = Image.open("C:/Users/hoo/Pictures/%s" % random.sample(names, 1)[0])
fromImage = fromImage.resize((100, 100), Image.ANTIALIAS)
toImage.paste(fromImage, ((x - 1) * mw, y * mw))
except IOError:
pass
toImage.show()
toImage.save('C:/Users/hoo/Desktop/ta.jpg')