Fixed script installation
This commit is contained in:
parent
ed223febd6
commit
82cac0a5a2
11 changed files with 80 additions and 55 deletions
21
colorcube.py
21
colorcube.py
|
|
@ -1,21 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Display an xterm-256color color palette on the terminal, including color ids
|
||||
|
||||
reset_sequence = '\033[39;49m'
|
||||
|
||||
def esc(i):
|
||||
return '\033[48;5;'+str(i)+'m'
|
||||
|
||||
print(''.join([str(i).ljust(4) for i in range(16)]))
|
||||
print(' '.join([esc(i) for i in range(16)])+' ' + reset_sequence)
|
||||
|
||||
for j in range(6):
|
||||
for k in range(6):
|
||||
c = 16+j*6+k*6*6
|
||||
print(''.join([str(c+i).ljust(4) for i in range(6)]))
|
||||
print(' '.join([esc(c+i) for i in range(6)])+' ' + reset_sequence)
|
||||
|
||||
print(''.join([str(i).ljust(4) for i in range(16+6*6*6, 16+6*6*6+24)]))
|
||||
print(' '.join([esc(i) for i in range(16+6*6*6, 16+6*6*6+24)])+' ' + reset_sequence)
|
||||
|
||||
25
pixelterm/colorcube.py
Executable file
25
pixelterm/colorcube.py
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Display an xterm-256color color palette on the terminal, including color ids
|
||||
|
||||
reset_sequence = '\033[39;49m'
|
||||
|
||||
def esc(i):
|
||||
return '\033[48;5;'+str(i)+'m'
|
||||
|
||||
def main():
|
||||
print(''.join([str(i).ljust(4) for i in range(16)]))
|
||||
print(' '.join([esc(i) for i in range(16)])+' ' + reset_sequence)
|
||||
|
||||
for j in range(6):
|
||||
for k in range(6):
|
||||
c = 16+j*6+k*6*6
|
||||
print(''.join([str(c+i).ljust(4) for i in range(6)]))
|
||||
print(' '.join([esc(c+i) for i in range(6)])+' ' + reset_sequence)
|
||||
|
||||
print(''.join([str(i).ljust(4) for i in range(16+6*6*6, 16+6*6*6+24)]))
|
||||
print(' '.join([esc(i) for i in range(16+6*6*6, 16+6*6*6+24)])+' ' + reset_sequence)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ clear_screen = '\033[H\033[2J'
|
|||
cursor_invisible = '\033[?25l'
|
||||
cursor_visible = '\033[?25h'
|
||||
|
||||
if __name__ == '__main__':
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Render pixel images on 256-color ANSI terminals')
|
||||
parser.add_argument('image', type=str)
|
||||
parser.add_argument('-s', '--size', type=str, help='Terminal size, [W]x[H]')
|
||||
|
|
@ -48,3 +48,6 @@ if __name__ == '__main__':
|
|||
print(frame)
|
||||
time.sleep(img.info['duration']/1000.0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ def termify_pixels(img):
|
|||
out = (out.rstrip() if bg == (0,0,0,0) else out) + '\n'
|
||||
return out[:-1] + reset_sequence + '\n'
|
||||
|
||||
if __name__ == '__main__':
|
||||
def main():
|
||||
import os, sys, argparse, os.path, json
|
||||
from multiprocessing import Pool
|
||||
from PIL import Image, PngImagePlugin
|
||||
|
|
@ -103,3 +103,7 @@ if __name__ == '__main__':
|
|||
|
||||
p = Pool()
|
||||
p.map(convert, args.image)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
16
pixelterm/pngmeta.py
Executable file
16
pixelterm/pngmeta.py
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os, sys, argparse
|
||||
from PIL import Image, PngImagePlugin
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Print PNG metadata')
|
||||
parser.add_argument('image', type=str)
|
||||
args = parser.parse_args()
|
||||
img = Image.open(args.image)
|
||||
for k, v in img.info.items():
|
||||
print('{:15}: {}'.format(k, v))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
17
pixelterm/resolvecolor.py
Executable file
17
pixelterm/resolvecolor.py
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
def main():
|
||||
import os, sys, argparse, os.path, json, re
|
||||
import xtermcolors
|
||||
|
||||
# Resolve HTML-style hex RGB color codes to xterm-256color color numbers
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print('Usage: resolvecolor.py #RRGGBB')
|
||||
exit()
|
||||
|
||||
print(xtermcolors.closest_color(*[int(s, 16) for s in re.match('#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})', sys.argv[1]).groups()]))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ def unpixelterm(text):
|
|||
x, y = 0, y+2
|
||||
return img, metadata
|
||||
|
||||
if __name__ == '__main__':
|
||||
def main():
|
||||
import argparse, json
|
||||
|
||||
parser = argparse.ArgumentParser(description='Convert images rendered by pixelterm-like utilities back to PNG')
|
||||
|
|
@ -116,3 +116,7 @@ if __name__ == '__main__':
|
|||
if args.output_dir:
|
||||
output = os.path.join(args.output_dir, os.path.basename(output))
|
||||
img.save(output, 'PNG', pnginfo=pnginfo)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
11
pngmeta.py
11
pngmeta.py
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os, sys, argparse
|
||||
from PIL import Image, PngImagePlugin
|
||||
|
||||
parser = argparse.ArgumentParser(description='Print PNG metadata')
|
||||
parser.add_argument('image', type=str)
|
||||
args = parser.parse_args()
|
||||
img = Image.open(args.image)
|
||||
for k, v in img.info.items():
|
||||
print('{:15}: {}'.format(k, v))
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os, sys, argparse, os.path, json, re
|
||||
import xtermcolors
|
||||
|
||||
# Resolve HTML-style hex RGB color codes to xterm-256color color numbers
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print('Usage: resolvecolor.py #RRGGBB')
|
||||
exit()
|
||||
|
||||
print(xtermcolors.closest_color(*[int(s, 16) for s in re.match('#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})', sys.argv[1]).groups()]))
|
||||
|
||||
15
setup.py
15
setup.py
|
|
@ -22,14 +22,15 @@ setup(name = 'pixelterm',
|
|||
author = 'jaseg',
|
||||
author_email = 'pixelterm@jaseg.net',
|
||||
url = 'https://github.com/jaseg/pixelterm',
|
||||
py_modules = ['pixelterm', 'unpixelterm', 'xtermcolors'],
|
||||
py_modules = ['pixelterm'],
|
||||
install_requires=['pillow'],
|
||||
scripts = ['pixelterm.py',
|
||||
'unpixelterm.py',
|
||||
'colorcube.py',
|
||||
'gifterm.py',
|
||||
'resolvecolor.py',
|
||||
'pngmeta.py'],
|
||||
entry_points = {'console_scripts': [
|
||||
'pixelterm=pixelterm.pixelterm:main',
|
||||
'unpixelterm=pixelterm.unpixelterm:main',
|
||||
'gifterm=pixelterm.gifterm:main',
|
||||
'colorcube=pixelterm.colorcube:main',
|
||||
'resolvecolor=pixelterm.resolvecolor:main',
|
||||
'pngmeta=pixelterm.pngmeta:main']},
|
||||
zip_safe = True,
|
||||
classifiers = [
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue