I'm a Python beginner. According to PyAutoGUI's documentation1, getpixel function returns a tuple of three numbers, (R,G,B) of course. However, my code returns a tuple of four numbers.
import pyautogui
from PIL import Image
img = Image.open("imagefilename.png")
print(img.getpixel((10,10)))
Return value should be for example (150, 210, 255)
, but in my case it was like (0, 150, 210, 255)
. With some simple analysis, I got to know the latter three numbers are R, G, B, respectively. Then what is the first number? Or, is something wrong with my Python environment?
Here are some of real return values.
(0, 168, 229, 255)
(63, 222, 250, 255)
(247, 244, 246, 255)
(0, 167, 229, 255)
(0, 168, 229, 255)
(0, 167, 233, 255)
mac OS X Sierra(10.12.4), Python 3.6, the code above was run on bash.
Colors can not only hold a RGB representation
there is too an RGBA
the Alpha component is just a value for the transparency
see in the image Lena behind a red circle(0xFF0000 ) alpha=0% and Lena behind a transparent red circle(0xFF0000 ) alpha=60%