Very nice! That color thief library would have made my work a lot easier.
Here's the process I did without pasting my embarrassingly hacky code:
* Accepted image from user
* Quantized the image down to 6 main colors (I forget how I arrived at this figure.)
* Slapped it on a canvas
* Generated a color histogram
* Converted RGB to HSB
* Did a border check of the image to determine the background color. Extended the border based on most common background
color if needed.
* Looked at the saturation of the colors to determine what might be interesting to use. Picked a primary and secondary color from that.
* From there I converted each of the color to YIQ to determine contrast levels to determine if I needed lighter or darker colors for the text.
* Generated some "accent" colors by modifying lightness levels of some of the primary and secondary colors.
From there I pretty much had the things I needed to make something theme-like.
Thanks for posting this. I enjoyed reading over the code. You also reminded me that I need to ditch my crappy JS tempting library that I wrote and switch to moustache.