Is it possible to change the color of one individual pixel in Python?
问题 I need python to change the color of one individual pixel on a picture, how do I go about that? 回答1: To build upon the example given in Gabi Purcaru's link, here's something cobbled together from the PIL docs. The simplest way to reliably modify a single pixel using PIL would be: x, y = 10, 25 shade = 20 from PIL import Image im = Image.open("foo.png") pix = im.load() if im.mode == '1': value = int(shade >= 127) # Black-and-white (1-bit) elif im.mode == 'L': value = shade # Grayscale