from torchvision import transforms
from PIL import Image
img = Image.open(r'C:\Users\Administrator\Pictures\test.jpg')
pad = max(img.size)
size = (pad,pad)
transform = transforms.Compose([
transforms.CenterCrop(size)
])
pad = transform(img)
pad.save('pad.jpg')