In this article, you’ll see how to crop an image in PIL Python. To crop an image you have to specify the exact position (points). In the following example, (0,0) is the start point, and (500, 300) is the endpoint.
# Import the PIL library
from PIL import Image
# Read the image from location
img = Image.open("C:\\AiHints\\cats.jpg")
# Crop the Image
crop_img = img.crop((0,0, 500,300))
# Show the Cropped Image
crop_img.show()
# Save the Cropped Image
crop_img.save("C:\\AiHints\\Cropped_Image.jpg")Output:

Recommendation: Computer Vision: Models, Learning, and Inference Book


