ในโปรแกรมนี้ เราจะครอปภาพโดยใช้ Pillow Library เราจะใช้ฟังก์ชัน crop() สำหรับวัตถุประสงค์นี้ ฟังก์ชันนี้รับพิกัดพิกเซล Left, Top, Right, Bottom เพื่อครอปภาพ
ภาพต้นฉบับ

อัลกอริทึม
Step 1: Import Image จาก Pillow
Step 2: อ่านภาพ
Step 3: ครอปภาพโดยใช้ฟังก์ชัน Crop
Step 4: แสดงผลลัพธ์
ตัวอย่างโค้ด
from PIL import Image
im = Image.open('testimage.jpg')
width, height = im.size
left = 5
top = height / 2
right = 164
bottom = 3 * height / 2
im1 = im.crop((left, top, right, bottom))
im1.show()
ผลลัพธ์
