from PIL import Image
from PIL import ImageFilter

im = Image.open("cats.jpeg")
print(im.size)
#im.show()

imageSize = 1500

big = Image.new("RGB", (imageSize*3, imageSize*3))

small = im.crop((0, 0, imageSize, imageSize))
small.save("cat-square.jpeg")

for row in range(3):
    for col in range(3):
        left = col * imageSize
        top = row * imageSize
        right = left + imageSize
        bottom = top + imageSize
        if (row + col) % 2 == 0:
            contour = small.filter(ImageFilter.CONTOUR)
            big.paste(contour, (left, top, right, bottom))
        else:
            big.paste(small, (left, top, right, bottom))
        small = small.rotate(90)
            
big.save("mosaic.jpg")