changing individual pixels the color of an individual pixel can be retrieved or set with the getpixel(and putpixel(methods these methods both take tuple representing the xand -coordinates of the pixel the putpixel(method also takes an additional tuple argument for the color of the pixel this color argument is four-integer rgba tuple or three-integer rgb tuple enter the following into the interactive shellfrom pil import image im image new('rgba'( ) im getpixel(( )( for in range( )for in range( ) im putpixel((xy)( )from pil import imagecolor for in range( )for in range( ) im putpixel((xy)imagecolor getcolor('darkgray''rgba')im getpixel(( )( im getpixel(( )( im save('putpixel png'at we make new image that is transparent square calling getpixel(on some coordinates in this image returns ( because the image is transparent to color pixels in this imagewe can use nested for loops to go through all the pixels in the top half of the image and color each pixel using putpixel( here we pass putpixel(the rgb tuple ( ) light gray manipulating images