# Make an image pastel

import Image   # the Image module from PIL

# Define functions we will use at the top of the file, right after imports


# Takes a primary color (r,g or b) as input, and
# produces a paler version of the color. 
def fade(primary):
    diff = 255 - primary
    primary = primary + (3*diff)/4
    return primary
    
# Function to make a color paler.
# Input parameter is an (r,g,b) color tuple
# Output is the paler version of the color. 
def pastel(color):
    red = fade(color[0])
    green = fade(color[1])
    blue = fade(color[2])
    return (red,green,blue) # Return a color tuple
    
# The main program
im = Image.open('turkey.jpg')
turkeySize = im.size  # size tuple
width = turkeySize[0]
height = turkeySize[1]

# Nested for loops to call function on every pixel
for x in range(width):
    for y in range(height):
        turkeyColor = im.getpixel((x,y))
        outColor = pastel(turkeyColor)
        im.putpixel((x,y), outColor)

        
im.show()  # display image


