aboutsummaryrefslogtreecommitdiff
path: root/gifterm.py
diff options
context:
space:
mode:
authorjaseg <s@jaseg.de>2013-09-16 15:33:01 +0200
committerjaseg <s@jaseg.de>2013-09-16 15:33:01 +0200
commit82cac0a5a211d573190253d3b40f89892bda713f (patch)
treeba67fa903d6b78c182df8b155e30ca46565e360b /gifterm.py
parented223febd651ea32bf784fb054ecb5082276cc6b (diff)
downloadpixelterm-82cac0a5a211d573190253d3b40f89892bda713f.tar.gz
pixelterm-82cac0a5a211d573190253d3b40f89892bda713f.tar.bz2
pixelterm-82cac0a5a211d573190253d3b40f89892bda713f.zip
Fixed script installation
Diffstat (limited to 'gifterm.py')
-rwxr-xr-xgifterm.py50
1 files changed, 0 insertions, 50 deletions
diff --git a/gifterm.py b/gifterm.py
deleted file mode 100755
index 185f741..0000000
--- a/gifterm.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env python
-
-import os, sys, argparse, os.path, json, time, signal, atexit, pixelterm
-from PIL import Image, GifImagePlugin, ImageSequence
-
-clear_screen = '\033[H\033[2J'
-cursor_invisible = '\033[?25l'
-cursor_visible = '\033[?25h'
-
-if __name__ == '__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]')
- args = parser.parse_args()
-
- tw, th = os.get_terminal_size()
- th = th*2
- if args.size:
- tw, th = map(int, args.size.split('x'))
-
- img = Image.open(args.image)
- palette = img.getpalette()
- last_frame = Image.new("RGBA", img.size)
- frames = []
-
- for frame in ImageSequence.Iterator(img):
- #This works around a known bug in Pillow
- #See also: http://stackoverflow.com/questions/4904940/python-converting-gif-frames-to-png
- frame.putpalette(palette)
- c = frame.convert("RGBA")
-
- if img.info['background'] != img.info['transparency']:
- last_frame.paste(c, c)
- else:
- last_frame = c
-
- im = last_frame.copy()
- im.thumbnail((tw, th), Image.NEAREST)
- frames.append(pixelterm.termify_pixels(im))
-
- print(cursor_invisible)
- atexit.register(lambda:print(cursor_visible))
- signal.signal(signal.SIGTERM, lambda signum, stack_frame: exit(1))
-
- while True:
- for frame in frames:
- print(clear_screen, pixelterm.reset_sequence)
- print(frame)
- time.sleep(img.info['duration']/1000.0)
-