How to set coordinates when cropping an image using PIL?

I do not know how to set the coordinates for cropping the image in PIL crop() :

 from PIL import Image img = Image.open("Supernatural.xlsxscreenshot.png") img2 = img.crop((0, 0, 201, 335)) img2.save("img2.jpg") 

I tried using gThumb to get the coordinates, but if I take the area that I would like to crop, I can find the position 194 336. Can someone help me?

This is my photo:

enter image description here

I want to do the following:

enter image description here

+5
source share
1 answer

How to set coordinates for cropping

In line:

 img2 = img.crop((0, 0, 201, 335)) 

the first two numbers define the upper left coordinates of the output (x, y), and the last two numbers determine the lower right coordinates of the output.

Image cropping

To crop the image as you show, I found the following coordinates: top-left: (200, 330) and right-bottom: (730, 606) . Subsequently, I cropped your image with:

 img2 = img.crop((200, 330, 730, 606)) 

enter image description here

with the result:

enter image description here

+5
source