Created
August 20, 2019 12:48
-
-
Save pta2002/ccc609af889e9313731594a56d76adda to your computer and use it in GitHub Desktop.
Preview GIMP palettes in your terminal
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
#!/bin/env python3 | |
# Requirements: truecolor | |
# Usage: colorpreview [file] | |
import truecolor | |
import sys | |
assert(len(sys.argv) >= 2) | |
for filename in sys.argv[1:]: | |
with open(filename) as file: | |
text = file.read() | |
print(filename + ":") | |
for line in text.split('\n')[1:]: | |
line = line.strip() | |
if len(line) == 0 or line[0] == "#": continue | |
line = line.split() | |
color = list(map(int, line[:3])) | |
color_block = truecolor.color_text(" ", background=color) | |
print(color_block, "{:3} {:3} {:3}".format(*color), line[3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment