#simple operations with Python Imaging Library and Pillow
#The default Canopy download already has the pillow package, so you should be ready to go

from PIL import Image

image2 = Image.new('RGB', (400,400), 0) #rgba for alpha layer
pixels = image2.load() #makes array of pixels
image2.show()

image1 = Image.open("fourSquid.jpg")
image1.show()

def diagonalRed(im):
    outIm = im.copy()
    pixels = outIm.load()
    for x in range(outIm.size[0]):
        pixels[x,x] = (255,0,0)
    return outIm

newIm = diagonalRed(image2)
newIm.show()

def closeEnough(a, b, distance):
    return abs(a - b) <= distance

def circleGreen(im):
    out = im.copy()
    pixels = out.load()
    for x in range(min(out.size)):
        for y in range(min(out.size)):
            if closeEnough((x-100)**2 + (y-100)**2, 5000, 500):
                pixels[x,y] = (0,255,0)
    return out
    
newIm = circleGreen(image1)
newIm.show()

newIm.save("squidWithCircle.png") #detects suffix