@Gargron Might be worth looking around the source of something like wal. It's a bit duff at generating full colour schemes (they tend to just be a few shades of a single colour - 2 if you're lucky), but it's very good at picking out accent colours from images.