[英]How to set coordinates when cropping an image with PIL?
I don't know how to set the coordinates to crop an image in PIL
s crop()
:我不知道如何设置坐标以在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 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?我尝试使用gThumb
获取坐标,但如果我选择一个我想裁剪的区域,我只能找到 position 194 336。有人可以帮我吗?
This is my picture:这是我的照片:
I wish to crop to this:我想裁剪成这样:
In the line:在行中:
img2 = img.crop((0, 0, 201, 335))
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.前两个数字定义了出口的左上角坐标 (x,y),而后两个数字定义了出口的右下角坐标。
To crop your image like you show, I found the following coordinates: top-left: (200, 330)
, and right-bottom: (730, 606)
.为了像您展示的那样裁剪图像,我找到了以下坐标:左上角: (200, 330)
和右下角: (730, 606)
。 Subsequently, I cropped your image with:随后,我用以下方法裁剪了您的图像:
img2 = img.crop((200, 330, 730, 606))
with the result:结果:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.