繁体   English   中英

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()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM