Use the PIL.Image.resize function to change the image size, but it doesn't work, the code is as follows:
img = Image.open(img_path)
img.resize((96, 96))
print(img.size)
The resize() function does not change the size of the img, because the resize() function does not change the size of the original image, but the return value can be assigned to a new image . The solution is as follows:
img = Image(img_path)
img = img.resize((96, 96))
print(img.size)