Spaces:
Runtime error
Runtime error
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 |