在支持Sixel的终端上查看全像素彩色图形(xterm/mlterm/decterm/reflection/rlogin/tanasinn/yaft)
PySixel的Python项目详细描述
Sixel是什么?
sixel是dec-vt系列引入的终端成像图像格式之一。 sixel图像数据方案被表示为一个终端友好的转义序列。 所以如果你想显示一个sixel图像文件,你所要做的就是把它“猫”到你的终端上。
另请参阅更快的高质量c实现 诽谤罪:https://github.com/saitoha/libsixel
我听说Sixel得到了一些旧的终端应用程序的支持,比如SAS、WordPerfect。
现在netpbm和gnuplot支持这一点。
要求
如果你想看Sixel图像,你必须要有一个终端 支持Sixel图形。
现在sixel特性由以下终端支持。
rlogin(日文终端仿真器)
Tanasinn(与Firefox一起使用)
mlterm
适用于x、win32/cygwin和帧缓冲区版本。 http://mlterm.sourceforge.net/
xterm(使用–enable sixel选项编译) 您应该启动带有“-ti 340”选项的xterm。 十六色调色板限制为最多16种颜色。 http://invisible-island.net/xterm/
十二月
克米特
WRQ反射
zstem
安装
通过Github
$ git clone https://github.com/saitoha/PySixel.git $ cd pysixel $ python setup.py install
或通过PIP
$ pip install PySixel
用法
pysixel提供了一个命令行工具:
$ sixelconv [options] filename
或
$ cat filename | sixelconv [options]
选项:
-h, --help show this help message and exit -8, --8bit-mode Generate a sixel image for 8bit terminal or printer -7, --7bit-mode Generate a sixel image for 7bit terminal or printer -r, --relative-position Treat specified position as relative one -a, --absolute-position Treat specified position as absolute one -x LEFT, --left=LEFT Left position in cell size, or pixel size with unit 'px' -y TOP, --top=TOP Top position in cell size, or pixel size with unit 'px' -w WIDTH, --width=WIDTH Width in cell size, or pixel size with unit 'px' -e HEIGHT, --height=HEIGHT Height in cell size, or pixel size with unit 'px' -t ALPHATHRESHOLD, --alpha-threshold=ALPHATHRESHOLD Alpha threshold for PNG-to-SIXEL image conversion -c, --chromakey Enable auto chroma key processing -n NCOLOR, --ncolor=NCOLOR Specify number of colors -b, --body-only Output sixel without header and DCS envelope -f, --fast The speed priority mode (default) -s, --size The size priority mode
示例
查看图像文件:
$ sixelconv test.png
从图像文件生成sixel文件:
$ sixelconv < test.png > test.six
查看生成的Sixel文件:
$ cat test.six
在xterm中显示sixel
$ curl ftp://invisible-island.net/xterm/xterm-301.tgz | tar xz $ cd xterm-301 $ ./configure --enable-wide-chars --enable-sixel-graphics --enable-256-color $ make # make install $ xterm -ti vt340 -e 'sixelconv -n16 ~/testdir/test.jpg'
代码示例
import sixel writer = sixel.SixelWriter() writer.draw('test.png')
依赖性
- Pillow https://github.com/python-imaging/Pillow
- Python imageloader module https://pypi.python.org/pypi/imageloader
出资人
- @cocuh (Python3 support)
参考
Chris_F_Chiesa, 1990 : All About SIXELs ftp://ftp.cs.utk.edu/pub/shuford/terminal/all_about_sixels.txt
Netpbm http://netpbm.sourceforge.net/
It includes ppmtosixel command http://netpbm.sourceforge.net/doc/ppmtosixel.html
vt100.net http://vt100.net/