簡體   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