-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2-nummer.py
25 lines (21 loc) · 1.04 KB
/
2-nummer.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
import os
from PIL import Image, ImageDraw, ImageFont
import shutil
source_folder = r'C:\dglmodules\chatgpt\1-resized'
destination_folder = r'C:\dglmodules\chatgpt\2-nummers'
files = os.listdir(source_folder)
for file_name in files:
shutil.copy(source_folder + '/' + file_name, destination_folder + '/' + file_name)
i = 1
for filename in os.listdir(destination_folder):
#print (filename)
nummer = filename.replace('dgl-102jaar-','').replace('_optimized.jpg','')
nummer = filename.replace('DGL 102jaar-','').replace('.jpg','')
if filename.endswith(".jpg") or filename.endswith(".png"):
image = Image.open(os.path.join(destination_folder, filename))
draw = ImageDraw.Draw(image)
font = ImageFont.truetype("arial.ttf", 50)
#draw.text((10, image.size[1]-400), str(i), (255, 0, 0), font=font) # unique number
draw.text((10, image.size[1]-60), str(nummer), (255, 0, 0), font=font) # filename number
image.save(os.path.join(destination_folder, filename))
i += 1