Chafa:21世纪的终端图形
Chafa: Terminal Graphics for the 21st Century

原始链接: https://hpjansson.org/chafa/

## Chafa:基于终端的图像与动画查看器 Chafa 使用 ANSI 转义码和 Unicode 符号,以令人惊讶的良好质量将图像和动画带到您的终端。它支持流行的图像格式,如 GIF,并输出到各种终端图形格式(Sixels、Kitty、iTerm2、Unicode 马赛克)。 与更简单的工具不同,Chafa 利用了更广泛的符号,并提供可定制的输出,包括全角字符支持和从自定义字体加载字形。它拥有多种颜色模式——甚至支持透明度——并使用 SIMD 和多线程进行速度优化。 除了直接使用外,Chafa 还提供稳定的 C API,以及 Python 和 JavaScript 绑定,可用于集成到其他应用程序中。社区 Matrix 聊天室提供支持和讨论,营造一个欢迎终端爱好者的环境。您可以在项目网站上找到示例和文档。

## Chafa:21世纪的终端图形 - 摘要 一篇Hacker News讨论强调了**Chafa**,一个用于创建终端图形的工具。用户称赞它能够在终端中渲染图像,并在更高级的协议(如Sixel或Kitty图形)不受支持时提供ASCII艺术作为替代方案。这使其在各种应用中用途广泛,包括命令行视频编辑器**vic**和TUI Jupyter客户端**euporie**。 该工具提供Python和JavaScript绑定(并提供浏览器演示),并且正在开发Rust绑定。用户欣赏Chafa的质量——其Unicode马赛克输出被认为优于传统的块或盲文字符方法。 除了Chafa本身,对话还涉及**Bubble Tea**和**notcurses**等替代方案,并回忆了DOS中较早的图形功能。 几位用户分享了他们使用Chafa的个人项目,展示了它与**term.everything**等工具的集成,以及它通过串口在硬件上显示徽标的实用性。 总而言之,Chafa被定位为一个强大而适应性强的解决方案,为终端带来现代图形。
相关文章

原文

The premier UX of the 21st century just got a little better: With chafa, you can now view very, very reasonable approximations of pictures and animations in the comfort of your favorite terminal emulator. The power of ANSI X3.64 compels you!

Example

You can get fair results by using only U+2580 (upper half block). Other terminal graphics packages do this, and so can Chafa with chafa --symbols vhalf. However, Chafa uses more symbols by default, greatly improving quality.

There are more examples in the gallery!

Features

  • Supports most popular image formats, including animated GIFs.
  • Outputs to all popular terminal graphics formats: Sixels, Kitty, iTerm2, Unicode mosaics.
  • Combines Unicode symbols from multiple selectable ranges for optimal output.
  • Fullwidth character support, e.g. Chinese, Japanese, Korean.
  • Glyphs can be loaded from any font file supported by Freetype (TTF, OTF, PCF, etc).
  • Multiple color modes, including Truecolor, 256-color, 16-color and simple FG/BG.
  • RGB and DIN99d color spaces for improved color picking.
  • Alpha transparency support in any color mode, including in animations.
  • Works with most modern and classic terminals and terminal emulators.
  • Documented, stable C API.
  • Fast & lean: SIMD optimized, multithreaded.
  • Suitable for terminal graphics, ANSI art composition and even black & white print.

Some of the features are discussed in a series of blog posts:

Documentation

Chafa will print a help text if run without arguments, or with chafa --help. It also comes with a man page displayable with man chafa.

The gallery contains examples of how command-line options can be used to tweak the output.

There is C API documentation for application developers.

Erica Ferrua Edwardsdóttir is developing Python bindings that allow Chafa to be used in Python programs. These are documented on their own site.

Héctor Molinero Fernández maintains JavaScript bindings that allow Chafa to be used in Node.js, web browsers, and more. These are documented on their own site.

Community

Please bring your questions to our secret business friendly Matrix chat. Stay a while and listen, or talk about terminals, software or your choice of breakfast cereal. All are welcome, but an appreciation for terminals, programming and/or computer graphics is likely to enhance your experience.

Friendly Chat

Although the chat's history is hidden from non-members, this is a public forum, so if your ambition is to overthrow the government/megacorps by way of an underground network of refurbished Minitels, you may want to keep it under your hat. Furthermore, and hopefully obviously, we treat our fellow humans with respect. Have fun!

联系我们 contact @ memedata.com