-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage combiner.py
30 lines (22 loc) · 937 Bytes
/
image combiner.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
import os
from PIL import Image
dirs = os.listdir("src")
combinacao = 1
try:
os.makedirs("out")
except OSError as error:
print(error)
for f1 in os.listdir("src/" + dirs[0]):
img1 = Image.open("src/" + dirs[0] + "/" + f1)
for f2 in os.listdir("src/" + dirs[1]):
img2 = Image.open("src/" + dirs[1] + "/" + f2)
for f3 in os.listdir("src/" + dirs[2]):
img3 = Image.open("src/" + dirs[2] + "/" + f3)
for f4 in os.listdir("src/" + dirs[3]):
img4 = Image.open("src/" + dirs[3] + "/" + f4)
final_img = Image.alpha_composite(img1, img2)
final_img = Image.alpha_composite(final_img, img3)
final_img = Image.alpha_composite(final_img, img4)
final_img.save("out/" + str(combinacao) + ".png")
print("combinações feitas: " + str(combinacao))
combinacao += 1