forked from vis4/eu-drought
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6-label.py
More file actions
32 lines (25 loc) · 868 Bytes
/
6-label.py
File metadata and controls
32 lines (25 loc) · 868 Bytes
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
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
import os
months = 'January,February,March,April,May,June,July,August,September,October,November,December'.split(',')
font1 = ImageFont.truetype("fonts/Roboto-Light.ttf", 70)
font2 = ImageFont.truetype("fonts/Roboto-Light.ttf", 50)
index = 0
def run(file):
global index
im = Image.open(file).convert('RGB')
draw = ImageDraw.Draw(im)
date= file[12:-4]
year=date[:4]
month=int(date[5:7])
print(year, month)
draw.text((90, 90), year, (60,60,60), font=font1)
draw.text((90, 170), months[month-1], (60,60,60), font=font2)
im2 = im.convert('P')
im2.save('labeled/frame-%03d.png' % index)
index += 1
# print( + (',%.4f'*6) % tuple(data_pct))
for file in sorted(os.listdir('resized')):
if file[-4:] == '.png':
run('resized/'+file)