Skip to content

Instantly share code, notes, and snippets.

@mePy2
Last active November 9, 2020 10:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mePy2/bb2f6f63af3f352378574ad1231555f5 to your computer and use it in GitHub Desktop.
Save mePy2/bb2f6f63af3f352378574ad1231555f5 to your computer and use it in GitHub Desktop.
Python script to convert GIMP exported palette to a .png color palette
from PIL import Image
array = bytearray()
colors = 0
with open("palette.txt") as palette:
for color in palette:
# print(color[1:7] + '\n')
data = bytearray.fromhex(color[1:7])
array += data
colors += 1
print(colors, ': ' + str(color) + '\n')
img = Image.frombytes('RGB', (colors,1), bytes(array))
img.save('palette.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment