from PIL import Image im = Image.open('dead_parrot.jpg') # Can be many different formats. pix = im.load() print im.size # Get the width and hight of the image for iterating over print pix[x,y] # Get the RGBA Value of the a pixel of an image pix[x,y] = value # Set the RGBA Value of the image (tuple) im.save('alive_parrot.png') # Save the modified pixels as .png
Here is what the above code is Doing:
1. Opening an image from the hard drive
2. Loading the image into memory
3. Getting the width and height of the image
4. Getting the RGBA value of a pixel
5. Setting the RGBA value of a pixel
6. Saving the image to the hard drive