Last active
November 9, 2020 10:54
-
-
Save mePy2/bb2f6f63af3f352378574ad1231555f5 to your computer and use it in GitHub Desktop.
Python script to convert GIMP exported palette to a .png color palette
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
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