需要取得圖片中的某一個區塊,想要剪裁圖片的範例如下:
from PIL import Image imageObject = Image.open(saved_image_path) box = (x_offset, Y_offset, width, height) crop = imageObject.crop(box) crop.save(saved_image_path, format)
資料來源:
https://stackoverflow.com/questions/6456479/python-pil-how-to-save-cropped-image
Python Pillow – Cropping an Image
https://www.tutorialspoint.com/python_pillow/python_pillow_cropping_an_image.htm