Proof of concept follows, as a simple bash script with ImageMagick to do the image processing work.
# Take all JPEGS in current directory and get their average RGB color and name in "tiles.txt"
for f in *.jpg; do convert $f -depth 8 -resize 1x1! -format "%[fx:int(mean.r*255)] %[fx:int(mean.g*255)] %[fx:int(mean.b*255)] $f\n" info: ; done > tiles.txt
# Create empty black output canvas same size as original map
convert map.png -threshold 100% result.png
# Split map into tiles of 10x10 and get x,y coordinates of each tile and the average RGB colour
convert map.png -depth 8 -crop 10x10 -format "%X %Y %[fx:int(mean.r*255)] %[fx:int(mean.g*255)] %[fx:int(mean.b*255)]\n" info: |
while read x y r g b; do
thumb=$(awk -v R=$r -v G=$g -v B=$b '
# Calculate distance (squared actually but sqrt is slow)
echo $x $y $r $g $b $thumb
convert result.png -draw "image copy $x,$y 10,10 \"$thumb\"" result.png
I don't have an endless supply of thumbnails but the concept seems to work. The maths of distance between colours is done in awk and obviously could be done in a more perceptually uniform colorspace and also things could be speeded up considerably. Another thought, to avoid repetition, might be to bin the tiles into similar colours and then take one at random from the nearest bin rather than the absolute nearest one.