Created
January 18, 2018 17:57
-
-
Save zaiste/3208d9729d49f07a38ff050cdbdec5fe to your computer and use it in GitHub Desktop.
Extract colors in Python
This file contains hidden or 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
import sys | |
import json | |
from haishoku.haishoku import Haishoku | |
colors = [] | |
if len(sys.argv) > 1: | |
url = sys.argv[1] | |
try: | |
palette = Haishoku.getPalette(url) | |
colors = [{'hex': '#%02x%02x%02x' % color[1], 'ratio': color[0]} for color in palette] | |
except: | |
pass | |
print(json.dumps(colors)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment