Skip to content
Advertisement

How to set coordinates when cropping an image with PIL?

I don’t know how to set the coordinates to crop an image in PILs crop():

JavaScript

I tried with gThumb to get coordinates, but if I take an area which I would like to crop, I can only find position 194 336. Could someone help me please?

This is my picture:

enter image description here

I wish to crop to this:

enter image description here

Advertisement

Answer

How to set the coordinates to crop

In the line:

JavaScript

the first two numbers define the top-left coordinates of the outtake (x,y), while the last two define the right-bottom coordinates of the outtake.

Cropping your image

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

JavaScript

enter image description here

with the result:

enter image description here

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement