'How to get actual Pixel Color value from PIL.ImageGrab.grab() in Python?
I'm trying to take a Pixel color value from the screen in Python
This is the example i'm doing to get the pixel at the position x=30 and y=30 on screen
def takePixel() :
rgb = PIL.ImageGrab.grab().load()[30,30]
How do i print out and store the actual pixel color value from this ?
Solution 1:[1]
ImageGrab.grab returns a PIL.Image object, which has a getpixel method.
def takePixel():
rgb = PIL.ImageGrab.grab().getpixel(30,30)
return rgb
print(takePixel())
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tim Roberts |
