在支持Sixel的终端上查看全像素彩色图形(xterm/mlterm/decterm/reflection/rlogin/tanasinn/yaft)

PySixel的Python项目详细描述


Sixel是什么?

https://raw.githubusercontent.com/saitoha/PySIXEL/data/data/sixel_gnuplot.png

sixel是dec-vt系列引入的终端成像图像格式之一。 sixel图像数据方案被表示为一个终端友好的转义序列。 所以如果你想显示一个sixel图像文件,你所要做的就是把它“猫”到你的终端上。

另请参阅更快的高质量c实现 诽谤罪:https://github.com/saitoha/libsixel

https://raw.githubusercontent.com/saitoha/PySIXEL/data/data/sixel_hikari.png

我听说Sixel得到了一些旧的终端应用程序的支持,比如SAS、WordPerfect。

现在netpbm和gnuplot支持这一点。

https://raw.githubusercontent.com/saitoha/PySIXEL/data/data/sixel_ls.png

要求

如果你想看Sixel图像,你必须要有一个终端 支持Sixel图形。

现在sixel特性由以下终端支持。

安装

通过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')

出资人

  • @cocuh (Python3 support)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何使用JNA创建同一库的多个实例?   java在将Graphql查询作为JSON字符串传递时收到意外的令牌错误   OAuth2 oltu的java问题   java桌面应用程序使用的好的嵌入式数据库是什么?   java Firebase数据库高级查询选项   java正在使磁盘上的EhCache元素过期   java 安卓还原处于backstack中的片段的实例状态   XMemcached中的java异步集   java TimescaleDB是否使用与Postgresql完全相同的JDBC驱动程序?   java从网站c读取信息#   检查java Android中的字符串是否只包含数字和空格   c#如何向web服务发送特殊字符?   grails无法调用需要java的方法。lang.类参数?   java我在组合框中调用的方法不会运行所有代码,它只运行部分代码   java发送带有标头的HTTP GET请求