Pick the dominant colour from a logo using Python

A hastily-written function to pluck the dominant colour from a logo. Works surprisingly well!

Example usage:

from PIL import Image

print '#%02x%02x%02x' % get_dominant_color(Image.open('logo.jpg'))

And the code: