Unicode ASCII art generator - Convert images and text to beautiful character art with wide character support
Project description
🎨 UnicodeArt
项目定位: unicode字符画生成程序 核心目标: 专注于算法清晰度、逻辑可读性、架构可移植性
本项目基于 asciifier 进行了改进:
- ✅ 优化程序结构和代码可读性
- ✅ 增强宽字符(中文/日文等)支持
- ✅ 完善参数配置和错误处理
- ✅ 提供完整的文档体系
🚀 快速开始
安装
方式 1: 从 PyPI 安装(推荐)
pip install unicodeart
方式 2: 从源码安装
git clone https://github.com/your-username/UnicodeArt.git
cd UnicodeArt
pip install -r requirements.txt
详细安装指南: 📦 安装说明
基础用法
文本转字符画
python unicodeart.py -t "Hello" --font "C:\Windows\Fonts\SimSun.ttc" --height 15
图片转字符画
python unicodeart.py -i photo.jpg --height 30 -o output.txt
5分钟快速入门: 🚀 快速入门教程
📚 文档导航
👥 用户文档
👨💻 开发者文档
🔬 算法文档
- 📊 算法总览 - 核心算法概览
- 🖼️ 图片转字符画 - 详细算法流程
- 📝 文本转字符画 - 文本渲染原理
- 🔤 字符匹配 - SAD 算法详解
- 🌏 宽字符处理 - 双字符集机制
- ⚡ 性能分析 - 复杂度分析和优化
🛠️ 工具集
算法可视化工具
python tools/visualizer.py --image test.png --height 20 --output-dir viz_output
生成:
- 采样网格 overlay
- 字符矩阵热力图
- HTML 逐步执行报告
性能基准测试
python tools/benchmark.py bench --image test.png --height 30
输出:
- 各阶段耗时
- 内存峰值
- Markdown/JSON 报告
⚙️ 命令行参数
python unicodeart.py [-h] (-i IMAGE | -t TEXT) [-o OUTPUT]
[--height HEIGHT] [--width WIDTH]
[--font FONT] [--chars CHARS]
[--ratio RATIO] [--matrix MATRIX]
[--font-style STYLE] [--font-reduce N]
[--interpolation ALGO] [--wide-char-ratio N]
[--height-mode MODE] [--line-spacing N]
[--invert] [--debug TAGS]
完整参数说明: 📚 功能详解
常用参数速查
| 参数 | 说明 | 默认值 |
|---|---|---|
-i, --image |
输入图片路径 | - |
-t, --text |
输入文本 | - |
-o, --output |
输出文件 | stdout |
--height |
输出高度 | - |
--font |
字体路径 | - |
--chars |
字符集 | " .:-=+*#%@" |
--ratio |
高宽比 | 2.0 |
--matrix |
采样矩阵大小 | 6 |
--interpolation |
插值算法 | bilinear |
🎯 典型用例
终端快速预览
python unicodeart.py -i photo.jpg --height 20 --matrix 4 --chars " ░▒▓█"
社交媒体分享
python unicodeart.py -i photo.jpg --height 50 -o output.txt
高质量打印
python unicodeart.py -i photo.jpg --height 100 --matrix 8 \
--chars " .'`^\",:;Il!i><~+_-?][}{1)(|\/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$" \
-o output.txt
中文文本 Banner
python unicodeart.py -t "你好世界" \
--font "C:\Windows\Fonts\SimSun.ttc" \
--height 20
说明:
- 默认
--ratio=2.0是标准值,无需指定 - 在混合等宽字体环境中(VSCode、现代终端),这是唯一正确配置
更多示例: 📖 使用示例集
🧪 测试
# 运行所有测试
pytest
# 生成 HTML 报告
pytest --html=tests/report.html
# 运行特定测试
pytest tests/test_character_matching.py -v
📊 性能特征
| 配置 | 相对速度 | 适用场景 |
|---|---|---|
matrix=4, nearest |
⚡⚡⚡⚡⚡ | 实时预览 |
matrix=6, bilinear |
⚡⚡⚡⚡ | 日常使用(推荐) |
matrix=8, bicubic |
⚡⚡⚡ | 高质量 |
matrix=10, lanczos |
⚡⚡ | 打印输出 |
详细性能分析: ⚡ 性能注意事项
🤝 贡献
欢迎提交 Issue 和 Pull Request!
贡献指南: 🤝 如何贡献
📄 许可证
GNU GPL v3 License
🔗 相关链接
- asciifier - 原始项目
🌐 多语言支持
最后更新: 2026-06-09
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unicodeart-1.0.0.tar.gz.
File metadata
- Download URL: unicodeart-1.0.0.tar.gz
- Upload date:
- Size: 107.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7436db1a8d8b405ea75e947d1233c7f98e1fad65cc387171d1cd8558dbd008e5
|
|
| MD5 |
82ebabd2bdab93864b79735e1067a8c4
|
|
| BLAKE2b-256 |
0d732b5e97496c52cf23a91d8f2c00a53f8e78e308242bc3b7d809c571e49ff4
|
File details
Details for the file unicodeart-1.0.0-py3-none-any.whl.
File metadata
- Download URL: unicodeart-1.0.0-py3-none-any.whl
- Upload date:
- Size: 44.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
482c6f8dd7c94e6da55de3e37a254b642ce7549ffd0b6900e81ddd1bed490fd0
|
|
| MD5 |
40a258388308419c6ca2838781224bf8
|
|
| BLAKE2b-256 |
0fccc177117ff7d699be6eece7134d680a1bb438e303e4558cea93478a84bfa8
|