Last active
August 3, 2021 13:31
-
-
Save saitoha/7546579 to your computer and use it in GitHub Desktop.
cat sixel file with penetrating GNU Screen
This file contains hidden or 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
% screen | |
% cat test.png | pngtopnm | pnmquant 256 | ppmtosixel | ./penetrate.py && cat | |
% cat test.png | sixelconv | ./penetrate.py && cat |
This file contains hidden or 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
#!/usr/bin/env python | |
from sys import stdin, stdout | |
while True: | |
s = stdin.read(512 - 8) | |
if not s: | |
break | |
s = s.replace("\x90", "\x1bP") | |
s = s.replace("\x9c", "\x1b\x1b\\\x1bP\\") | |
s = s.replace("\x1b\\", "\x1b\x1b\\\x1bP\\") | |
stdout.write("\x1bP") | |
stdout.write(s) | |
stdout.write("\x1b\\") | |
stdout.flush() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See also img2sixel's -P option