Easy PIL question

Gary Herron gherron at islandtraining.com
Sat Feb 16 12:14:10 EST 2008


Adam W. wrote:
> I know there is an easy way to do this, but I can't figure it out, how
> do I get the color of a pixel?  I used the ImageGrab method and I want
> to get the color of a specific pixel in that image.  If you know how
> to make it only grab that pixel, that would also be helpful.
> Basically I'm trying to make a:
> if pixel == color:
>     do_this()
> else:
>     pass
>
> And have it do this as fast as my pc can handle (that is why only
> grabbing 1px would be helpful)
>   
Try image.getpixel((x,y)) to retrieve the pixel at (x,y).

Gary Herron





More information about the Python-list mailing list