import os
from PIL import Image

input = open("photomosaic_input.txt").read().splitlines()

solution = Image.new("RGB", (180*32, 110*32))

for line in input:
    x,y,img=line.split(",")
    x = int(x.strip())
    y = int(y.strip())
    img = Image.open(os.path.join("imagettes_espions", "{:03d}".format(int(img.strip()))+".jpeg"))
    solution.paste(img, (y*32,x*32))

solution.show()
solution.save("photomosaic_input.jpg")

    