Answers for "SystemError: tile cannot extend outside image"

1

SystemError: tile cannot extend outside image

def crop_center(pil_img, crop_width, crop_height):
    img_width, img_height = pil_img.size
    return pil_img.crop(((img_width - crop_width) // 2,
                         (img_height - crop_height) // 2,
                         (img_width + crop_width) // 2,
                         (img_height + crop_height) // 2))
                         
                         
im_new = crop_center(im, 300, 150)
im_new.save('img.jpg', quality=95)
Posted by: Guest on January-18-2022

Python Answers by Framework

Browse Popular Code Answers by Language