I want to make a photomosaic. This is a photo made up of a lot of little photos. First I devide the picture in a given number of squares. I analyses every pixel to get the average color in this particular square. Then I search in my DB for the picture closed to this color.

I made it in PHP and GD2. Everything is working as it is supposed to, but a normal picture takes up to 50 sec loading time. Now I’m searching for solution. Maybe another language?

So my question is, is there a better language to make this script or a totally different approach maybe?