Get pixel's RGB using PIL
问题 Is it possible to get the RGB color of a pixel using PIL? I'm using this code: im = Image.open("image.gif") pix = im.load() print(pix[1,1]) However, it only outputs a number (e.g. 0 or 1 ) and not three numbers (e.g. 60,60,60 for R,G,B). I guess I'm not understanding something about the function. I'd love some explanation. Thanks a lot. 回答1: Yes, this way: im = Image.open('image.gif') rgb_im = im.convert('RGB') r, g, b = rgb_im.getpixel((1, 1)) print(r, g, b) (65, 100, 137) The reason you