import os
from PIL import Image
import numpy as np

directory = "/home/mia/Schule/KISY/schrifterkennung/out"

files = os.listdir(f"{directory}/BigDataSet")
print(files)
labels = []
images = []
for letter in files:
    dir = f"{directory}/BigDataSet/{letter}"
    i = 0
    os.makedirs(f"{directory}/Scaled/{letter}/", exist_ok=True)
    for image in os.listdir(dir)[:]:
        print(image)
        img = Image.open(os.path.join(dir, image))
        res = img.resize((32,32))
        res = res.convert("L")
        images.append(res)
        labels.append(letter)  # Label ist der Ordnername
        res.save(f"{directory}/Scaled/{letter}/miakieler_{i}.png")
        i += 1

X = np.array(images)
Y = np.array(labels)

np.save('images_big.npy', X)
np.save('labels_big.npy', Y)
