File size: 371 Bytes
5081207
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
def resize_img(image):
    new_height = 480 if image.height > 480 else image.height
    new_height -= (new_height % 32)
    new_width = int(new_height * image.width / image.height)
    diff = new_width % 32
    new_width = new_width - diff if diff < 16 else new_width + 32 - diff
    new_size = (new_width, new_height)
    image = image.resize(new_size)

    return image