I\'m trying to resize a batch of grayscale images that are 256 x N pixels (N varies, but is always ≤256).
My intention is to downscale the images.
The resiz
from PIL import Image
def reshape(image):
'''
Reshapes the non-square image by pasting
it to the centre of a black canvas of size
n*n where n is the biggest dimension of
the non-square image.
'''
old_size = image.size
max_dimension, min_dimension = max(old_size), min(old_size)
desired_size = (max_dimension, max_dimension)
position = int(max_dimension/2) - int(min_dimension/2)
blank_image = Image.new("RGB", desired_size, color='black')
if image.height