-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresize.py
32 lines (22 loc) · 1.06 KB
/
resize.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
from ImageManager import ImageManager
import os
fontSizes = ["24", "28", "32", "36", "40", "44", "48", "56", "72"]
fileNumbers = [str(5+3*i) for i in range(52)]
def resize(charType, font, width, height):
oldPathStump = "res/dataset (cropped and digitised)/"
newPathStump = "res/dataset (resized " + str(width) + "x" + str(height) + ")/"
for i in range(len(fontSizes)):
for j in range(len(fileNumbers)):
pathStem = charType + "/" + font + "/" + fontSizes[i] + "/line_" + fileNumbers[j] + ".bmp"
img = ImageManager.openImage(oldPathStump + pathStem)
img = img.resize((width, height))
ImageManager.saveImage(img, newPathStump + pathStem)
print(newPathStump + pathStem)
if __name__ == "__main__":
width = 20
height = 24
resize("Letters", "Arial", width, height)
resize("Letters", "Times New Roman", width, height)
fileNumbers = fileNumbers[:10]
resize("Numbers", "Arial", width, height)
resize("Numbers", "Times New Roman", width, height)