From 76bc6482a61421b016c4722347f78f892c4120b4 Mon Sep 17 00:00:00 2001 From: jaseg Date: Sat, 6 Apr 2013 13:18:58 +0200 Subject: Added a basic unpixelterm script. Misses metadata support. --- unpixelterm.py | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100755 unpixelterm.py diff --git a/unpixelterm.py b/unpixelterm.py new file mode 100755 index 0000000..b5a9bf4 --- /dev/null +++ b/unpixelterm.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python + +import os, sys, argparse +#NOTE: This script uses pygments for X256->RGB conversion since pygments is +#readily available. If you do not like pygments (e.g. because it is large), +#you could patch in something like https://github.com/magarcia/python-x256 +#(but don't forget to send me a pull request ;) +from pygments.formatters import terminal256 +from PIL import Image, PngImagePlugin +try: + import re2 as re +except: + import re + +formatter = terminal256.Terminal256Formatter() + +def parse_escape_sequence(seq): + codes = list(map(int, seq.lstrip('\x1b[').rstrip('m').split(';'))) + fg, bg = None, None + i = 0 + while i