Last active
January 3, 2016 19:39
-
-
Save svschannak/8509908 to your computer and use it in GitHub Desktop.
Get most used color from an image and its complementary color with python and PIL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pic = Image.open('/path/to/image.jpg') | |
sorted_list = sorted(pic.getcolors(pic.size[0]*pic.size[1])) | |
#get complementary color of picture | |
comp = ['%s' % (255 - int(a)) for a in sorted_list[-1][1]] | |
color1 = '#%02x%02x%02x' % (sorted_list[-1][1]) | |
color2 = '#%02x%02x%02x' % (int(comp[0]), int(comp[1]), int(comp[2])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment