Photomosaics or: How Many Programmers Does it Take to Replace a Light Bulb?
Mathematica, with control for granularity
This uses the 48 x 48 pixel photos, as required.  By default, it will swap those pixels for a corresponding 48x48 pixel square from the image to be approximated.
However, the size of the destination squares  can be set to be smaller than 48 x 48, allowing for greater fidelity to detail.  (see the examples below).
Preprocessing the palette
collage is the image containing the photos to serve as the palette.
picsColorsis a list of individual photos paired with their mean red, mean green, and mean blue values.
 targetColorToPhoto[]` takes the average color of the target swath and finds the photo from the palette that best matches it.
parts=Flatten[ImagePartition[collage,48],1];
picsColors={#,c=Mean[Flatten[ImageData[#],1]]}&amp;/@parts;
nf=Nearest[picsColors[[All,2]]];

targetColorToPhoto[p_]:=Cases[picsColors,{pic_,nf[p,1][[1]]}:&gt;pic][[1]]

Example
Let's find the photo that best matches RGBColor[0.640, 0.134, 0.249]:


photoMosaic
photoMosaic[rawPic_, targetSwathSize_: 48] :=
 Module[{targetPic, data, dims, tiles, tileReplacements, gallery},
  targetPic = Image[data = ImageData[rawPic] /. {r_, g_, b_, _} :&gt; {r, g, b}];
  dims = Dimensions[data];
  tiles = ImagePartition[targetPic, targetSwathSize];
  tileReplacements = targetColorToPhoto /@ (Mean[Flatten[ImageData[#], 1]] &amp; /@Flatten[tiles, 1]);
  gallery = ArrayReshape[tileReplacements, {dims[[1]]/targetSwathSize,dims[[2]]/targetSwathSize}];
  ImageAssemble[gallery]]

`photoMosaic takes as input the raw picture we will make a photo mosaic of.
targetPic will remove a fourth parameter (of PNGs and some JPGs), leaving only R, G, B.
dims are the dimensions of targetPic.
tiles are the little squares that together comprise the target picture.
targetSwathSize is the granularity parameter; it defaults at 48 (x48).
tileReplacements are the photos that match each tile, in proper order.
gallery is the set of tile-replacements (photos) with the proper dimensionality (i.e. the number of rows and columns that match the tiles).
ImageAssembly joins up the mosaic into a continuous output image.

Examples
This replaces each 12x12 square from the image, Sunday, with a corresponding 48 x 48 pixel photograph that best matches it for average color.
photoMosaic[sunday, 12]



Sunday (detail)


photoMosaic[lightbulb, 6]



photoMosaic[stevejobs, 24]



Detail, stevejobs.


photoMosaic[kiss, 24]



Detail of the Kiss:


photoMosaic[spheres, 24]