Monthly Archives: February 2014

Image Color Dominator

Most anyone who’s used iTunes’ album view will know about their color picking mechanism.  I was curious about how this might be done and found this question on Stack Overflow: How does the algorithm to color the song list in iTunes 11 work?

So I set about creating an equivalent in PHP.  I settled on using the IMagick PHP extension for grabbing pixel data and doing blurs.

The Results

mizu Mizu (Water)

moon Tsuki (Moon)

fall Aki (Fall)

Chibi Chibi ^_^

The How

It’s largely based on the accepted answer given on the Stack Overflow question mentioned earlier. Except I separate potential highlights from the selected background based on a luminance ratio which produces more readable text, and there’s some additional logic for trying to pick contrasting highlight colors.

The Source

Source is available on BitBucket: Not much in the way of documentation, so hopefully the comments on the class aren’t horrifically confusing. I’ll re-read them later and maybe make changes.