'''
Created on Mar 7, 2016

@author: rodger
'''
#import Image
from PIL import Image



def makeGray(pixel):
    (r,g,b) = pixel
    gray = (r+g+b)/3
    return (gray,gray,gray)


def colorme(picname,pixelchanger,filenameadd):
    im = Image.open(picname)
    im.show()
    pixels = [pixelchanger(pix) for pix in im.getdata()]
    nim = Image.new("RGB",im.size)
    nim.putdata(pixels)
    nim.show()
    nim.save(filenameadd+picname)
    
    
if __name__ == '__main__':
    imagefile = "bluedevil.png"
    imagefile2 = "eastereggs.jpg"
    colorme(imagefile2, makeGray, "gray")
    colorme(imagefile, makeGray, "gray")
