File size: 483 Bytes
5b020c1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
def crop_to_multiple_of_16(img):
width, height = img.size
# Calculate new dimensions that are multiples of 8
new_width = width - (width % 16)
new_height = height - (height % 16)
# Calculate crop box coordinates
left = (width - new_width) // 2
top = (height - new_height) // 2
right = left + new_width
bottom = top + new_height
# Crop the image
cropped_img = img.crop((left, top, right, bottom))
return cropped_img |