Skip to main content

ansify

Build status Python Version Dependencies Status

Code style: black Security: bandit Pre-commit Semantic Versions License

Awesome ansify is a Python CLI to create ANSI/ASCII art from images.

好玩的终端图片艺术工具

工具特点

  • 任意图片转成任意字符
  • 支持彩色输出

使用说明

安装工具 ansify

pip install -U ansify

Let's go

原图

  • 黑白
ansify --columns 120 --no-color examples/ycy.jpg

  • 彩色
ansify --columns 120 examples/ycy.jpg

  • 像素
ansify --columns 120 --grayscale pixel examples/ycy.jpg

  • 自定义字符
ansify --columns 120 --diy-grayscale "你我爱超越" examples/ycy.jpg

  • 其他示例
ansify --columns 80 --diy-grayscale " 谁咬我苹果" examples/apple.png

ansify --columns 80 --grayscale emoji examples/apple.png

ansify https://b-ssl.duitang.com/uploads/item/201712/06/20171206200408_txunr.thumb.700_0.jpeg

参数说明

$ ansify --help
Usage: ansify [OPTIONS] IMAGE

  CLI to create ANSI/ASCII art from images.

Arguments:
  IMAGE  Image file PATH or URL.  [required]

Options:
  -c, --columns INTEGER           Output columns, number of characters per
                                  line.  [default: 252]

  -o, --output PATH               Save ANSI/ASCII art to the OUTPUT file.
  -s, --scale FLOAT               The larger the scale, the thinner the art.
                                  [default: 0.43]

  -g, --grayscale [simple|morelevels|pixel|dragon|emoji]
                                  Choose a built-in gray scale.  [default:
                                  simple]

  -d, --diy-grayscale TEXT        Customize your gray scale.
  -n, --no-color                  Output a ANSI/ASCII art without color.
                                  [default: False]

  -r, --reverse-grayscale         Reverse the grayscale.  [default: False]
  -R, --reverse-color             Reverse the color.  [default: False]
  -q, --quite                     Hide output information.  [default: False]
  -v, --version                   Prints the version of the ansify package.
  --help                          Show this message and exit.

必要参数:

  • IMAGE: 本地图片文件路径,或者网络图片 URL

可选参数:

  • -c, --columns:转化后图片的列数(汉字占两个字符,列数会减半),默认为终端的宽度
  • -o, --output:指定文件名如 output.txt 后,将输出字符保存到文件
  • -s, --scale:受终端配置(字间距、行高)与字符长宽比的影响,输出图像的长宽比与原图有差别。必要时使用此参数调整长宽比,该值越大,图片越高瘦
  • -g, --grayscale:预设的几种灰阶递增(字符越来越密集)字符,[simple|morelevels|pixel|dragon|emoji]
  • -d, --diy-grayscale:自定义灰阶字符,可以是单字符,多字符最好灰阶递增或递减
  • -n, --no-color:禁用彩色
  • -r, --reverse-grayscale:灰阶字符反转,终端背景为亮色时可以试试看
  • -R, --reverse-color:颜色反转
  • -q, --quite:输出结果中,屏蔽除字符图的其他信息

其他:

  • -v, --version:打印工具版本信息
  • --help:打印工具使用说明

Release History

1.0.0

Initial release on PyPI.

🛡 License

License

This project is licensed under the terms of the MIT license. See LICENSE for more details.

📃 Citation

@misc{ansify,
  author = {lonsty},
  title = {Awesome `ansify` is a Python CLI to create ANSI/ASCII art from images.},
  year = {2021},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/lonsty/ansify}}
}

Credits

This project was generated with python-package-template.

Metadata

Release files for ansify 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ansify 0.1.0
File Size Uploaded Provenance Actions
ansify-0.1.0.tar.gz 9.0 kB Without provenance Details for ansify-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ansify 0.1.0
File Interpreter ABI Platform Actions
ansify-0.1.0-py3-none-any.whl Python 3 none any Details for ansify-0.1.0-py3-none-any.whl

Total release size: 17.7 kB

Release files / ansify-0.1.0.tar.gz

Download URL ansify-0.1.0.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
644cb3375fad359ead22da98539d9e7af1b8822a1d925c5453a0b11fdb9d9848
BLAKE2b-256 checksum
How to use checksums
701282aa487abfe3e966cda631f3aa5ed572d10b12a9c8120d02ea64772d2b9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.5 CPython/3.6.12 Linux/4.19.128-microsoft-standard

Release files / ansify-0.1.0-py3-none-any.whl

Download URL ansify-0.1.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
290bf736d319a83611c9c39de9fb62fea76580e87638a3232d5a366f7c925f8b
BLAKE2b-256 checksum
How to use checksums
af2d9e2d2fcd44b4e3edcf695ccdcf50c8afc217a96c4ae4b07c5a09afe55a27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.5 CPython/3.6.12 Linux/4.19.128-microsoft-standard

Security for ansify 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page