-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
45 lines (38 loc) · 876 Bytes
/
main.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
from PIL import Image
import glob
from process import getDominantColor
import os
COLORS = [
"red",
"orange",
"yellow",
"spring green",
"green",
"turquoise",
"cyan",
"ocean",
"blue",
"violet",
"magenta",
"raspberry",
"black",
"white",
]
if not os.path.exists('input'):
os.makedirs('input')
if not os.path.exists('output'):
os.makedirs('output')
for item in COLORS:
if not os.path.exists('output/'+item):
os.makedirs('output/'+item)
path, dirs, files = next(os.walk('input/'))
file_count = len(files)
count = 1
for filename in glob.glob('input/*'):
try:
im = Image.open(filename)
temp = getDominantColor(im, str(filename[8:]))
print('('+str(count)+'/'+str(file_count)+') , '+temp)
count = count+1
except:
print(str(filename) + ' is not an image')