Because I wanted to understand how that works, I created a small web application that extracts mains colors from an image file, resulting in a color palette.
The application is available online. The core is really small, it is a simple implementation of a quantizer using an histogram. The N most frequent colors are then used to compose the palette.
Source code available at https://github.com/dgellow/imgcolor.