in src/edge/run.py [0:0]
def get_square_image(img):
"""Returns a squared image by adding black padding"""
padding_color = (0, 0, 0)
width, height = img.size
if width == height:
return img
elif width > height:
result = PIL.Image.new(img.mode, (width, width), padding_color)
result.paste(pil_img, (0, (width - height) // 2))
return result
else:
result = PIL.Image.new(img.mode, (height, height), padding_color)
result.paste(img, ((height - width) // 2, 0))
return result