-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom-nft-generator.py
73 lines (69 loc) · 2.19 KB
/
random-nft-generator.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
import glob
import PIL
from PIL import Image
import random
how_many = 10
list_fh = []
list_f = []
list_m = []
list_e = []
list_mp = []
list_h = []
for x in glob.glob('layers-infinite/m/Facial Hair/*'):
list_fh.append(x)
for x in glob.glob('layers-infinite/m/faces-m/*'):
list_f.append(x)
for x in glob.glob('layers-infinite/m/Mouth/*'):
list_m.append(x)
for x in glob.glob('layers-infinite/m/Mouth Prop/*'):
list_mp.append(x)
for x in glob.glob('layers-infinite/m/Eyes/*'):
list_e.append(x)
for x in glob.glob('layers-infinite/m/Hair/*'):
list_h.append(x)
w=600
h=600
n=0
dumb = Image.open("layers-infinite/dumb-real.png")
while n < how_many:
fn = (random.choice(list_f))
fhn = (random.choice(list_fh))
mn = (random.choice(list_m))
mpn = (random.choice(list_mp))
en = (random.choice(list_e))
hhn = (random.choice(list_h))
f = Image.open(fn).resize((w,h),0).convert("RGBA")
fh = Image.open(fhn).resize((w,h),0).convert("RGBA")
m = Image.open(mn).resize((w,h),0).convert("RGBA")
mp = Image.open(mpn).resize((w,h),0).convert("RGBA")
e = Image.open(en).resize((w,h),0).convert("RGBA")
hh = Image.open(hhn).resize((w,h),0).convert("RGBA")
f.paste(fh, (0, 0),fh)
f.paste(m, (0, 0),m)
f.paste(mp, (0, 0),mp)
f.paste(e, (0, 0),e)
f.paste(hh, (0, 0),hh)
pic_l,pic_u,pic_r,pic_d=f.getbbox()
punked = f.crop((0,pic_u,pic_r,600))
black = Image.new('RGBA', punked.size)
myImage = Image.composite(punked, black, punked)
punked = punked.crop((0,0,pic_r,600))
punked
new_size = (600,punked.size[1]+120)
new_im = Image.new("RGBA", new_size)
new_im.paste(punked,(0,120))
new_im.paste(dumb,(0,0))
f = new_im
pic_l,pic_u,pic_r,pic_d=f.getbbox()
punked = f.crop((0,pic_u,pic_r,pic_d))
black = Image.new('RGBA', punked.size)
myImage = Image.composite(punked, black, punked)
f = punked.crop((pic_l,pic_u,pic_r,pic_d))
f.save("layers-infinite/infinite-sample/m/{}_{}_{}_{}_{}_{}.png".format(fn.split("/")[-1][:-4], hhn.split("/")[-1][:-4], en.split("/")[-1][:-4],mn.split("/")[-1][:-4],mpn.split("/")[-1][:-4],fhn.split("/")[-1][:-4]))
del f
del fh
del m
del mp
del e
del hh
n+=1