Last active
December 19, 2015 21:28
-
-
Save dobrych/6019979 to your computer and use it in GitHub Desktop.
made a quick script that generates json list of rgb values from png row, useful for palette reading # pip install pypng
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
import png | |
f = open('palette.png', 'r') | |
p = png.Reader(f) | |
res = p.read() | |
palette = res[3]['palette'] | |
data = list(res[2]) | |
# second row, first one could be distorted | |
# data[1] | |
json_palette = ["rgb%s" % str(palette[v]) for v in data[1]] | |
print json_palette |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment