How to resize from rectangle to square

I have a few rectangle figures and I wanna reshape them to square, is there a way besides doing cropping? For example, if I have a figure with size 20050, and I wanna a 4040, then the desired way is to scale x axis to 20% and y to 80%. Thanks!!

You can specify the desired size as a tuple in torchvision.transforms.Resize

1 Like