Skip to content

Instantly share code, notes, and snippets.

@dobrych
Last active December 19, 2015 21:28
Show Gist options
  • Save dobrych/6019979 to your computer and use it in GitHub Desktop.
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
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