"""

This script resizes dataset photos to unified size (512 x 512 px)

"""

from PIL import Image
import glob

PATH_IN  = "C:\\Users\\I530265\\Desktop\\DATASET_NEUPRAVENY\\"
PATH_OUT = "C:\\Users\\I530265\\Desktop\\DATASET_UPRAVENY\\"

def resize():
    print("Processing "+str(len(glob.glob(PATH_IN + "*.jp*g")))+" images...")  # All JPG or JPEG images
    for image in glob.glob(PATH_IN + "*.jp*g"):
        imgName = image.split("\\")[-1]
        resized = Image.open(image).resize((512, 512), Image.ANTIALIAS)
        resized.save(PATH_OUT + imgName, 'JPEG', quality=95)

resize()