9951 explained code solutions for 126 technologies


python-pillowHow to get pixel color value


from PIL import Image

im = Image.open('/var/www/examples/small.png')
rgb = im.getpixel((20, 20))ctrl + c
PIL

import Pillow package modules

Image.open

open given image with Pillow

.getpixel(

returns pixel color value based on given coordinates

(20, 20)

get pixel color at 20 from left and 20 from top

rgb

will contain tuple of 3 (or 4) items representing RGB values (and opacity when relevant)