Perhaps a little more optimized:
imagePool = Map[With[{i = Import[#]}, {i, N@Mean [Flatten[ImageData[i], 1]]}] &, FileNames["Pool/*.jpg"]]; closeMatch[c_] := RandomChoice[ Nearest[imagePool[[All, 2]] -> imagePool[[All, 1]], c, 20]] ImageAssemble[Map[closeMatch, ImageData[Import["mendeleevIcon.tif"]], {2}]]

Edit
The reason the source code stops working in version 8 is because, prior to Mathematica version 6, Import["file.jpg"] will return a Graphics[Raster[]] object. To extract the image data, you can simply do Import["file.jpg"][[1,1]] . However, in version 8 (and I suspect version 7), bitmaps are imported as Image by default, which means that you need ImageData to extract image data from the imported files. You can import bitmaps as Graphics[Raster[]] using Import["file.jpg","Graphics"] so that the source code works anyway if you adapt Import statements, but the advantage of using Image objects is that you can use features like ImageAssemble (plus a host of other image processing tools that come with Mathematica 8).
Heike source share