While using the grab function from PIL.ImageGrab, there\'s a parameter called bbox, which specifies the bounding box of which the screengrab should be taken. And when I want
You've made two mistakes:
Since you've specified a bounding box, the resulting image is smaller than your screen resolution. The bounding box is a (left_x, top_y, right_x, bottom_y)
tuple, so with the values (500, 500, 600, 700)
, the image has a width of 100 pixels and a height of 200 pixels.
That explains why im.getpixel(510, 510)
doesn't work - the coordinate 510 is outside of the image.
The getpixel method takes the coordinates as a (x, y)
tuple, not as two separate arguments. The correct syntax is im.getpixel((10, 10))
.