PIL 裁剪图像 python

PIL crop image python

这是我的代码:

from PIL import Image

image = Image.open('/root/Downloads/crew.jpg')

Left = int(input('Left : '))
Right = int(input('Right : '))
Upper = int(input('Upper : '))
Lower = int(input('Lower : '))

values = Left, Right, Upper, Lower
crop_image = image.crop(values)
crop_image.show()

但是当我执行这段代码时,它显示了这个错误:

    fh = fp.fileno()
    AttributeError: '_idat' object has no attribute 'fileno'

请帮我解决这个错误。

裁剪图像的点应作为元组给出。

from PIL import Image

image = Image.open('xxxx.jpg')

Left = int(input('Left : '))
Right = int(input('Right : '))
Upper = int(input('Upper : '))
Lower = int(input('Lower : '))

values = (Left, Right, Upper, Lower)
crop_image = image.crop(values)
crop_image.show()