框選圖中位置
代碼
from PIL import Image,ImageDraw,ImageFont,ImageFilter import random#------------------------------------- #filepath,[837,103][942,208]#圖片處理,框選 def pic_rectangle(filepath,bound):image = Image.open(filepath)draw = ImageDraw.Draw(image)# 坐標x1, y1 =bound[0]x2, y2 =bound[1]# outline 外線,fill填充draw.rectangle((x1, y1, x2, y2), outline="red", width=5)image.save('filepath', 'jpeg')#image.show()if __name__=="__main__":#調用filepath="./image/name.jpg"bound=[[744, 276],[1014, 366]]pic_rectangle(filepath,bound)
?