How did they do that?

http://www.etsy.com/color.php here the link.

is there some type of algorithm to check the primary color of a image, may be then they kept trace of that in a Db?

I want to reproduced that. well not that swf but how they made a catalog by the color of a item. Way cool if you ask, I see potential for photo catalog and arts of all kinds.