asciify-graphic 1.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- asciify_graphic-1.2.1/LICENSE +21 -0
- asciify_graphic-1.2.1/PKG-INFO +297 -0
- asciify_graphic-1.2.1/README.md +268 -0
- asciify_graphic-1.2.1/asciify/__init__.py +132 -0
- asciify_graphic-1.2.1/asciify/charsets.py +29 -0
- asciify_graphic-1.2.1/asciify/cli.py +444 -0
- asciify_graphic-1.2.1/asciify/config.py +98 -0
- asciify_graphic-1.2.1/asciify/converter.py +177 -0
- asciify_graphic-1.2.1/asciify/downloader.py +279 -0
- asciify_graphic-1.2.1/asciify/fonts.py +137 -0
- asciify_graphic-1.2.1/asciify/renderer.py +197 -0
- asciify_graphic-1.2.1/asciify/storage.py +82 -0
- asciify_graphic-1.2.1/asciify/video.py +407 -0
- asciify_graphic-1.2.1/asciify_graphic.egg-info/PKG-INFO +297 -0
- asciify_graphic-1.2.1/asciify_graphic.egg-info/SOURCES.txt +26 -0
- asciify_graphic-1.2.1/asciify_graphic.egg-info/dependency_links.txt +1 -0
- asciify_graphic-1.2.1/asciify_graphic.egg-info/entry_points.txt +3 -0
- asciify_graphic-1.2.1/asciify_graphic.egg-info/requires.txt +9 -0
- asciify_graphic-1.2.1/asciify_graphic.egg-info/top_level.txt +1 -0
- asciify_graphic-1.2.1/pyproject.toml +44 -0
- asciify_graphic-1.2.1/setup.cfg +4 -0
- asciify_graphic-1.2.1/setup.py +25 -0
- asciify_graphic-1.2.1/tests/test_cli.py +66 -0
- asciify_graphic-1.2.1/tests/test_converter.py +84 -0
- asciify_graphic-1.2.1/tests/test_downloader.py +78 -0
- asciify_graphic-1.2.1/tests/test_renderer.py +72 -0
- asciify_graphic-1.2.1/tests/test_storage.py +68 -0
- asciify_graphic-1.2.1/tests/test_video.py +82 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ahmad Hazem Al-Damisi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: asciify-graphic
|
|
3
|
+
Version: 1.2.1
|
|
4
|
+
Summary: A powerful tool to convert any picture or video file into an ASCII code picture, animation video, or interactive terminal playback.
|
|
5
|
+
Author: asciify developers
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: ascii,ascii-art,video-to-ascii,image-to-ascii,animation,terminal
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
15
|
+
Classifier: Topic :: Multimedia :: Video
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: numpy>=1.20
|
|
20
|
+
Requires-Dist: pillow>=9.0
|
|
21
|
+
Requires-Dist: opencv-python-headless>=4.5
|
|
22
|
+
Requires-Dist: imageio>=2.20
|
|
23
|
+
Requires-Dist: imageio-ffmpeg>=0.4
|
|
24
|
+
Requires-Dist: click>=8.0
|
|
25
|
+
Requires-Dist: rich>=12.0
|
|
26
|
+
Requires-Dist: requests>=2.25
|
|
27
|
+
Requires-Dist: yt-dlp>=2024.0.0
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# asciify-graphic 🎨✨
|
|
31
|
+
|
|
32
|
+
> Convert any image or video file into an ASCII code picture, rasterized graphic, or animation video with full-color rendering, audio preservation, and real-time terminal playback.
|
|
33
|
+
|
|
34
|
+
[](https://github.com/Ahmad-H-PS/asciify-graphic/actions/workflows/ci.yml)
|
|
35
|
+
[](https://opensource.org/licenses/MIT)
|
|
36
|
+
[](https://www.python.org/downloads/)
|
|
37
|
+
|
|
38
|
+
<p align="center">
|
|
39
|
+
<img src="https://raw.githubusercontent.com/Ahmad-H-PS/asciify-graphic/main/examples/flower_blooming.gif" alt="ASCII version of a blooming flower animation" width="600">
|
|
40
|
+
<br>
|
|
41
|
+
<sub>Made with asciify-graphic. Original animation: <a href="https://www.youtube.com/watch?v=siL3cLng6Es">"Flower blooming - animation practice"</a> by xaloriun.</sub>
|
|
42
|
+
</p>
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## ✨ Features
|
|
47
|
+
|
|
48
|
+
- **Any Image & Video Format**: Supports PNG, JPG, JPEG, WEBP, BMP, GIF, MP4, MKV, AVI, MOV, WebM, and more.
|
|
49
|
+
- **Direct URLs & YouTube Streaming**: Convert pictures and videos directly from web links, including YouTube, shorts, and video platforms.
|
|
50
|
+
- **Multiple Output Formats**:
|
|
51
|
+
- **Rasterized Graphics**: Render high-definition ASCII graphics (`.png`, `.jpg`, `.webp`) using a pre-rendered vectorized font atlas.
|
|
52
|
+
- **Animation Videos**: Render full-length ASCII animation videos (`.mp4`, `.mkv`, `.avi`, `.webm`) with **audio track preservation**.
|
|
53
|
+
- **Animated GIFs**: Render compact, shareable ASCII animations (`.gif`).
|
|
54
|
+
- **HTML Webpages**: Standalone `.html` files styled with monospace CSS and TrueColor RGB spans.
|
|
55
|
+
- **ANSI Terminal Art**: 24-bit TrueColor ANSI terminal output (`.ans`, `.ansi`, or direct stdout).
|
|
56
|
+
- **Plain Text**: Clean ASCII art text files (`.txt`).
|
|
57
|
+
- **Interactive Terminal Video Player**: Stream videos directly inside your terminal in real-time (`asciify play <video>`) with synchronized FPS and interactive controls (pause/resume with Space, quit with `q`).
|
|
58
|
+
- **Rich Character Sets & Ramps**:
|
|
59
|
+
- `standard`: `@%#*+=-:. `
|
|
60
|
+
- `detailed`: 70-character fine-grained luminance gradient
|
|
61
|
+
- `blocks`: Unicode block shading elements `█▓▒░ `
|
|
62
|
+
- `matrix`: Authentic Katakana and numeric character rain `ヲアウ...`
|
|
63
|
+
- `binary`: Tech aesthetic `10 `
|
|
64
|
+
- `dots`: Braille dot density `⣿⣶⣤⣀ `
|
|
65
|
+
- *Custom*: Any custom character ramp specified on the CLI or API!
|
|
66
|
+
- **Color Modes**:
|
|
67
|
+
- `color`: 24-bit RGB TrueColor matching source pixels
|
|
68
|
+
- `grayscale`: Luminance-mapped monochrome shading
|
|
69
|
+
- `matrix`: Iconic cyberpunk Matrix green phosphor glow
|
|
70
|
+
- `amber`: Retro amber CRT monitor glow
|
|
71
|
+
- `cyan`: Vivid neon cyan styling
|
|
72
|
+
- `monochrome`: Custom foreground color on dark background
|
|
73
|
+
- **Visual Enhancements**:
|
|
74
|
+
- Automatic aspect ratio correction (monospace character width-to-height ratio)
|
|
75
|
+
- Sobel edge detection & contour enhancement (`--edge`)
|
|
76
|
+
- Adjustable brightness, contrast, and gamma correction
|
|
77
|
+
- Invert brightness ramp (`--invert`)
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 🚀 Installation
|
|
82
|
+
|
|
83
|
+
Clone the repository and install with `pip`:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
git clone https://github.com/Ahmad-H-PS/asciify-graphic.git
|
|
87
|
+
cd asciify-graphic
|
|
88
|
+
pip install -e .
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
All video encoding and decoding dependencies (including FFmpeg) are bundled self-contained via `imageio-ffmpeg` and `opencv-python-headless`.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 💻 CLI Usage
|
|
96
|
+
|
|
97
|
+
The tool installs the `asciify` (and alias `asciify-graphic`) command.
|
|
98
|
+
|
|
99
|
+
### 1. Smart Auto-Detection
|
|
100
|
+
|
|
101
|
+
`asciify` automatically detects whether your input is an image, video, direct URL, or YouTube link:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Print image as ASCII to terminal (local or URL)
|
|
105
|
+
asciify photo.jpg
|
|
106
|
+
asciify https://example.com/logo.png
|
|
107
|
+
|
|
108
|
+
# Stream a YouTube video directly in your terminal in real-time!
|
|
109
|
+
asciify https://www.youtube.com/watch?v=dQw4w9WgXcQ
|
|
110
|
+
|
|
111
|
+
# Convert a YouTube video to an ASCII animation video (audio preserved)
|
|
112
|
+
asciify https://www.youtube.com/watch?v=dQw4w9WgXcQ -o rickroll_ascii.mp4
|
|
113
|
+
|
|
114
|
+
# Save online image as ASCII PNG graphic
|
|
115
|
+
asciify https://picsum.photos/400/300 -o ascii_art.png
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
### 2. Image Conversion (`asciify image`)
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# Print to terminal with auto-fitted width
|
|
124
|
+
asciify image photo.jpg
|
|
125
|
+
|
|
126
|
+
# Save as a high-resolution ASCII PNG graphic
|
|
127
|
+
asciify image photo.jpg -o ascii_art.png --width 120 --font-size 18
|
|
128
|
+
|
|
129
|
+
# Generate a standalone interactive HTML page
|
|
130
|
+
asciify image photo.jpg -o art.html --width 100
|
|
131
|
+
|
|
132
|
+
# Save plain text ASCII art
|
|
133
|
+
asciify image photo.jpg -o art.txt --width 80
|
|
134
|
+
|
|
135
|
+
# Classic Matrix green style
|
|
136
|
+
asciify image photo.jpg -o matrix.png -m matrix -c matrix
|
|
137
|
+
|
|
138
|
+
# Block shading with edge enhancement
|
|
139
|
+
asciify image photo.jpg -o blocks.png -c blocks --edge
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Common Image Options:**
|
|
143
|
+
- `-o, --output <path>`: Target output file (`.txt`, `.ans`, `.html`, `.png`, `.jpg`, `.webp`)
|
|
144
|
+
- `-w, --width <int>`: Number of ASCII columns (default: 100 or terminal width)
|
|
145
|
+
- `-H, --height <int>`: Number of ASCII rows (auto-computed from aspect ratio if omitted)
|
|
146
|
+
- `-c, --charset <name|string>`: Character set preset (`standard`, `detailed`, `blocks`, `matrix`, `binary`, `dots`, `minimal`) or custom string
|
|
147
|
+
- `-m, --color-mode <mode>`: `color`, `grayscale`, `matrix`, `amber`, `cyan`, `monochrome`, `none`
|
|
148
|
+
- `--edge`: Enable Sobel edge detection to highlight contours
|
|
149
|
+
- `--brightness <float>` / `--contrast <float>` / `--gamma <float>`: Image adjustments
|
|
150
|
+
- `--bg <color>` / `--fg <color>`: Background and foreground colors (`#000000`, `black`, `white`, etc.)
|
|
151
|
+
- `--font-size <int>`: Font size in pixels for rendered images (default: 16)
|
|
152
|
+
- `--font-path <path>`: Custom TTF/OTF monospace font file
|
|
153
|
+
|
|
154
|
+
When you save an image with a bare filename (for example, `-o art.png`), it is placed in the `ASCIIFY` folder under your Pictures folder (`~/Pictures/ASCIIFY` on macOS/Linux or `%USERPROFILE%\Pictures\ASCIIFY` on Windows). If you omit `-o`, image conversion prints to the terminal instead. To save elsewhere, provide a path such as `-o ./art.png`.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
### 3. Video Conversion (`asciify video`)
|
|
159
|
+
|
|
160
|
+
Convert any video into a rendered ASCII animation video or animated GIF:
|
|
161
|
+
|
|
162
|
+
Video exports are saved in the `ASCIIFY` folder under your Videos folder (`~/Videos/ASCIIFY` on macOS/Linux or `%USERPROFILE%\Videos\ASCIIFY` on Windows) when you provide a bare filename. If `-o` is omitted from the `video` command, it creates a default `<input>_ascii.mp4` there. Provide a path such as `-o ./animation.mp4` to save elsewhere.
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Convert video to MP4 animation (audio is preserved by default!)
|
|
166
|
+
asciify video clip.mp4 -o ascii_animation.mp4 --width 120
|
|
167
|
+
|
|
168
|
+
# Convert directly from a YouTube link (full video or preview)
|
|
169
|
+
asciify video "https://www.youtube.com/watch?v=dQw4w9WgXcQ" -o rickroll.mp4
|
|
170
|
+
asciify video "https://www.youtube.com/watch?v=dQw4w9WgXcQ" -o rickroll_preview.mp4 --max-frames 120
|
|
171
|
+
|
|
172
|
+
# Convert video to animated GIF
|
|
173
|
+
asciify video clip.mp4 -o animation.gif --width 80 --fps 15
|
|
174
|
+
|
|
175
|
+
# Matrix style video conversion
|
|
176
|
+
asciify video clip.mp4 -o matrix_clip.mp4 -m matrix -c matrix
|
|
177
|
+
|
|
178
|
+
# Skip frames for fast preview (process every 2nd frame)
|
|
179
|
+
asciify video clip.mp4 -o fast.mp4 --step 2
|
|
180
|
+
|
|
181
|
+
# Limit number of frames
|
|
182
|
+
asciify video clip.mp4 -o preview.mp4 --max-frames 60
|
|
183
|
+
|
|
184
|
+
# Export frame sequence to directory
|
|
185
|
+
asciify video clip.mp4 -o output_frames/
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
### 4. Live Terminal Video Player (`asciify play`)
|
|
191
|
+
|
|
192
|
+
Play any video directly inside your terminal in real-time:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
# Play video in terminal (auto-fits terminal dimensions)
|
|
196
|
+
asciify play clip.mp4
|
|
197
|
+
|
|
198
|
+
# Play with Matrix styling in an infinite loop
|
|
199
|
+
asciify play clip.mp4 -m matrix -c matrix --loop
|
|
200
|
+
|
|
201
|
+
# Play with block shading
|
|
202
|
+
asciify play clip.mp4 -c blocks
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**Player Controls:**
|
|
206
|
+
- `Space`: Pause / Resume
|
|
207
|
+
- `q` or `ESC`: Quit player
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
### 5. Inspect Media & Character Sets
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
# List all built-in character set ramps
|
|
215
|
+
asciify charsets
|
|
216
|
+
|
|
217
|
+
# Display resolution, framerate, and duration of media
|
|
218
|
+
asciify info clip.mp4
|
|
219
|
+
asciify info photo.jpg
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## 🐍 Python Library API
|
|
225
|
+
|
|
226
|
+
You can also use `asciify` directly in your Python code:
|
|
227
|
+
|
|
228
|
+
### Image Conversion
|
|
229
|
+
|
|
230
|
+
```python
|
|
231
|
+
from asciify import AsciiConfig, AsciiConverter, AsciiRenderer, convert_image
|
|
232
|
+
|
|
233
|
+
# One-liner to convert and save (local file or direct image URL)
|
|
234
|
+
convert_image("https://example.com/photo.jpg", "output.png", width=120, color_mode="color")
|
|
235
|
+
|
|
236
|
+
# Advanced programmatic access
|
|
237
|
+
config = AsciiConfig(
|
|
238
|
+
width=100,
|
|
239
|
+
charset="detailed",
|
|
240
|
+
color_mode="matrix",
|
|
241
|
+
edge_detect=True,
|
|
242
|
+
brightness=1.1,
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
converter = AsciiConverter(config)
|
|
246
|
+
frame = converter.convert_image("photo.jpg")
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Video Conversion & Playback
|
|
250
|
+
|
|
251
|
+
```python
|
|
252
|
+
from asciify import convert_video, play_video
|
|
253
|
+
|
|
254
|
+
# Convert video (local file or YouTube link) to MP4 animation with audio
|
|
255
|
+
convert_video(
|
|
256
|
+
input_path="https://www.youtube.com/watch?v=dQw4w9WgXcQ",
|
|
257
|
+
output_path="output_ascii.mp4",
|
|
258
|
+
width=120,
|
|
259
|
+
color_mode="color",
|
|
260
|
+
keep_audio=True,
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
# Convert video to GIF
|
|
264
|
+
convert_video("input.mp4", "output_ascii.gif", width=80, fps=12)
|
|
265
|
+
|
|
266
|
+
# Stream video or YouTube link directly in terminal
|
|
267
|
+
play_video("https://www.youtube.com/watch?v=dQw4w9WgXcQ", color_mode="cyan", loop=False)
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## ⚡ Performance Architecture
|
|
273
|
+
|
|
274
|
+
`asciify-graphic` is engineered for high throughput:
|
|
275
|
+
1. **Vectorized Character Mapping**: Grayscale luminance quantization and character lookups run in native C via NumPy arrays.
|
|
276
|
+
2. **Glyph Atlas Blitting**: Font glyph alpha masks are pre-rendered once into an atlas `(N, char_h, char_w, 1)`. Frame compositing operates via vectorized broadcast multiplication, achieving **~60+ FPS per CPU core** for HD frames.
|
|
277
|
+
3. **Run-Length Optimized ANSI**: Adjacent terminal characters sharing identical RGB colors are collapsed into single escape sequences, minimizing string overhead and maximizing terminal refresh rates.
|
|
278
|
+
4. **Self-Contained FFmpeg Muxing**: Direct H.264 video streaming and audio muxing without requiring external system package installations.
|
|
279
|
+
5. **Smart URL & YouTube Caching**: Direct images and YouTube streams are downloaded once to local cache with SHA-256 validation to avoid redundant downloads.
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## 🧪 Testing
|
|
284
|
+
|
|
285
|
+
Run the test suite with `pytest`:
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
pytest -v
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
All 28 unit and integration tests verify image conversion, video rendering, audio muxing, glyph atlas rasterization, URL downloads, YouTube format merging, and CLI dispatch.
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## 📄 License
|
|
296
|
+
|
|
297
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# asciify-graphic 🎨✨
|
|
2
|
+
|
|
3
|
+
> Convert any image or video file into an ASCII code picture, rasterized graphic, or animation video with full-color rendering, audio preservation, and real-time terminal playback.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/Ahmad-H-PS/asciify-graphic/actions/workflows/ci.yml)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://www.python.org/downloads/)
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img src="https://raw.githubusercontent.com/Ahmad-H-PS/asciify-graphic/main/examples/flower_blooming.gif" alt="ASCII version of a blooming flower animation" width="600">
|
|
11
|
+
<br>
|
|
12
|
+
<sub>Made with asciify-graphic. Original animation: <a href="https://www.youtube.com/watch?v=siL3cLng6Es">"Flower blooming - animation practice"</a> by xaloriun.</sub>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## ✨ Features
|
|
18
|
+
|
|
19
|
+
- **Any Image & Video Format**: Supports PNG, JPG, JPEG, WEBP, BMP, GIF, MP4, MKV, AVI, MOV, WebM, and more.
|
|
20
|
+
- **Direct URLs & YouTube Streaming**: Convert pictures and videos directly from web links, including YouTube, shorts, and video platforms.
|
|
21
|
+
- **Multiple Output Formats**:
|
|
22
|
+
- **Rasterized Graphics**: Render high-definition ASCII graphics (`.png`, `.jpg`, `.webp`) using a pre-rendered vectorized font atlas.
|
|
23
|
+
- **Animation Videos**: Render full-length ASCII animation videos (`.mp4`, `.mkv`, `.avi`, `.webm`) with **audio track preservation**.
|
|
24
|
+
- **Animated GIFs**: Render compact, shareable ASCII animations (`.gif`).
|
|
25
|
+
- **HTML Webpages**: Standalone `.html` files styled with monospace CSS and TrueColor RGB spans.
|
|
26
|
+
- **ANSI Terminal Art**: 24-bit TrueColor ANSI terminal output (`.ans`, `.ansi`, or direct stdout).
|
|
27
|
+
- **Plain Text**: Clean ASCII art text files (`.txt`).
|
|
28
|
+
- **Interactive Terminal Video Player**: Stream videos directly inside your terminal in real-time (`asciify play <video>`) with synchronized FPS and interactive controls (pause/resume with Space, quit with `q`).
|
|
29
|
+
- **Rich Character Sets & Ramps**:
|
|
30
|
+
- `standard`: `@%#*+=-:. `
|
|
31
|
+
- `detailed`: 70-character fine-grained luminance gradient
|
|
32
|
+
- `blocks`: Unicode block shading elements `█▓▒░ `
|
|
33
|
+
- `matrix`: Authentic Katakana and numeric character rain `ヲアウ...`
|
|
34
|
+
- `binary`: Tech aesthetic `10 `
|
|
35
|
+
- `dots`: Braille dot density `⣿⣶⣤⣀ `
|
|
36
|
+
- *Custom*: Any custom character ramp specified on the CLI or API!
|
|
37
|
+
- **Color Modes**:
|
|
38
|
+
- `color`: 24-bit RGB TrueColor matching source pixels
|
|
39
|
+
- `grayscale`: Luminance-mapped monochrome shading
|
|
40
|
+
- `matrix`: Iconic cyberpunk Matrix green phosphor glow
|
|
41
|
+
- `amber`: Retro amber CRT monitor glow
|
|
42
|
+
- `cyan`: Vivid neon cyan styling
|
|
43
|
+
- `monochrome`: Custom foreground color on dark background
|
|
44
|
+
- **Visual Enhancements**:
|
|
45
|
+
- Automatic aspect ratio correction (monospace character width-to-height ratio)
|
|
46
|
+
- Sobel edge detection & contour enhancement (`--edge`)
|
|
47
|
+
- Adjustable brightness, contrast, and gamma correction
|
|
48
|
+
- Invert brightness ramp (`--invert`)
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 🚀 Installation
|
|
53
|
+
|
|
54
|
+
Clone the repository and install with `pip`:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
git clone https://github.com/Ahmad-H-PS/asciify-graphic.git
|
|
58
|
+
cd asciify-graphic
|
|
59
|
+
pip install -e .
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
All video encoding and decoding dependencies (including FFmpeg) are bundled self-contained via `imageio-ffmpeg` and `opencv-python-headless`.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 💻 CLI Usage
|
|
67
|
+
|
|
68
|
+
The tool installs the `asciify` (and alias `asciify-graphic`) command.
|
|
69
|
+
|
|
70
|
+
### 1. Smart Auto-Detection
|
|
71
|
+
|
|
72
|
+
`asciify` automatically detects whether your input is an image, video, direct URL, or YouTube link:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Print image as ASCII to terminal (local or URL)
|
|
76
|
+
asciify photo.jpg
|
|
77
|
+
asciify https://example.com/logo.png
|
|
78
|
+
|
|
79
|
+
# Stream a YouTube video directly in your terminal in real-time!
|
|
80
|
+
asciify https://www.youtube.com/watch?v=dQw4w9WgXcQ
|
|
81
|
+
|
|
82
|
+
# Convert a YouTube video to an ASCII animation video (audio preserved)
|
|
83
|
+
asciify https://www.youtube.com/watch?v=dQw4w9WgXcQ -o rickroll_ascii.mp4
|
|
84
|
+
|
|
85
|
+
# Save online image as ASCII PNG graphic
|
|
86
|
+
asciify https://picsum.photos/400/300 -o ascii_art.png
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### 2. Image Conversion (`asciify image`)
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Print to terminal with auto-fitted width
|
|
95
|
+
asciify image photo.jpg
|
|
96
|
+
|
|
97
|
+
# Save as a high-resolution ASCII PNG graphic
|
|
98
|
+
asciify image photo.jpg -o ascii_art.png --width 120 --font-size 18
|
|
99
|
+
|
|
100
|
+
# Generate a standalone interactive HTML page
|
|
101
|
+
asciify image photo.jpg -o art.html --width 100
|
|
102
|
+
|
|
103
|
+
# Save plain text ASCII art
|
|
104
|
+
asciify image photo.jpg -o art.txt --width 80
|
|
105
|
+
|
|
106
|
+
# Classic Matrix green style
|
|
107
|
+
asciify image photo.jpg -o matrix.png -m matrix -c matrix
|
|
108
|
+
|
|
109
|
+
# Block shading with edge enhancement
|
|
110
|
+
asciify image photo.jpg -o blocks.png -c blocks --edge
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Common Image Options:**
|
|
114
|
+
- `-o, --output <path>`: Target output file (`.txt`, `.ans`, `.html`, `.png`, `.jpg`, `.webp`)
|
|
115
|
+
- `-w, --width <int>`: Number of ASCII columns (default: 100 or terminal width)
|
|
116
|
+
- `-H, --height <int>`: Number of ASCII rows (auto-computed from aspect ratio if omitted)
|
|
117
|
+
- `-c, --charset <name|string>`: Character set preset (`standard`, `detailed`, `blocks`, `matrix`, `binary`, `dots`, `minimal`) or custom string
|
|
118
|
+
- `-m, --color-mode <mode>`: `color`, `grayscale`, `matrix`, `amber`, `cyan`, `monochrome`, `none`
|
|
119
|
+
- `--edge`: Enable Sobel edge detection to highlight contours
|
|
120
|
+
- `--brightness <float>` / `--contrast <float>` / `--gamma <float>`: Image adjustments
|
|
121
|
+
- `--bg <color>` / `--fg <color>`: Background and foreground colors (`#000000`, `black`, `white`, etc.)
|
|
122
|
+
- `--font-size <int>`: Font size in pixels for rendered images (default: 16)
|
|
123
|
+
- `--font-path <path>`: Custom TTF/OTF monospace font file
|
|
124
|
+
|
|
125
|
+
When you save an image with a bare filename (for example, `-o art.png`), it is placed in the `ASCIIFY` folder under your Pictures folder (`~/Pictures/ASCIIFY` on macOS/Linux or `%USERPROFILE%\Pictures\ASCIIFY` on Windows). If you omit `-o`, image conversion prints to the terminal instead. To save elsewhere, provide a path such as `-o ./art.png`.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### 3. Video Conversion (`asciify video`)
|
|
130
|
+
|
|
131
|
+
Convert any video into a rendered ASCII animation video or animated GIF:
|
|
132
|
+
|
|
133
|
+
Video exports are saved in the `ASCIIFY` folder under your Videos folder (`~/Videos/ASCIIFY` on macOS/Linux or `%USERPROFILE%\Videos\ASCIIFY` on Windows) when you provide a bare filename. If `-o` is omitted from the `video` command, it creates a default `<input>_ascii.mp4` there. Provide a path such as `-o ./animation.mp4` to save elsewhere.
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# Convert video to MP4 animation (audio is preserved by default!)
|
|
137
|
+
asciify video clip.mp4 -o ascii_animation.mp4 --width 120
|
|
138
|
+
|
|
139
|
+
# Convert directly from a YouTube link (full video or preview)
|
|
140
|
+
asciify video "https://www.youtube.com/watch?v=dQw4w9WgXcQ" -o rickroll.mp4
|
|
141
|
+
asciify video "https://www.youtube.com/watch?v=dQw4w9WgXcQ" -o rickroll_preview.mp4 --max-frames 120
|
|
142
|
+
|
|
143
|
+
# Convert video to animated GIF
|
|
144
|
+
asciify video clip.mp4 -o animation.gif --width 80 --fps 15
|
|
145
|
+
|
|
146
|
+
# Matrix style video conversion
|
|
147
|
+
asciify video clip.mp4 -o matrix_clip.mp4 -m matrix -c matrix
|
|
148
|
+
|
|
149
|
+
# Skip frames for fast preview (process every 2nd frame)
|
|
150
|
+
asciify video clip.mp4 -o fast.mp4 --step 2
|
|
151
|
+
|
|
152
|
+
# Limit number of frames
|
|
153
|
+
asciify video clip.mp4 -o preview.mp4 --max-frames 60
|
|
154
|
+
|
|
155
|
+
# Export frame sequence to directory
|
|
156
|
+
asciify video clip.mp4 -o output_frames/
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
### 4. Live Terminal Video Player (`asciify play`)
|
|
162
|
+
|
|
163
|
+
Play any video directly inside your terminal in real-time:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Play video in terminal (auto-fits terminal dimensions)
|
|
167
|
+
asciify play clip.mp4
|
|
168
|
+
|
|
169
|
+
# Play with Matrix styling in an infinite loop
|
|
170
|
+
asciify play clip.mp4 -m matrix -c matrix --loop
|
|
171
|
+
|
|
172
|
+
# Play with block shading
|
|
173
|
+
asciify play clip.mp4 -c blocks
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Player Controls:**
|
|
177
|
+
- `Space`: Pause / Resume
|
|
178
|
+
- `q` or `ESC`: Quit player
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
### 5. Inspect Media & Character Sets
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# List all built-in character set ramps
|
|
186
|
+
asciify charsets
|
|
187
|
+
|
|
188
|
+
# Display resolution, framerate, and duration of media
|
|
189
|
+
asciify info clip.mp4
|
|
190
|
+
asciify info photo.jpg
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## 🐍 Python Library API
|
|
196
|
+
|
|
197
|
+
You can also use `asciify` directly in your Python code:
|
|
198
|
+
|
|
199
|
+
### Image Conversion
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
from asciify import AsciiConfig, AsciiConverter, AsciiRenderer, convert_image
|
|
203
|
+
|
|
204
|
+
# One-liner to convert and save (local file or direct image URL)
|
|
205
|
+
convert_image("https://example.com/photo.jpg", "output.png", width=120, color_mode="color")
|
|
206
|
+
|
|
207
|
+
# Advanced programmatic access
|
|
208
|
+
config = AsciiConfig(
|
|
209
|
+
width=100,
|
|
210
|
+
charset="detailed",
|
|
211
|
+
color_mode="matrix",
|
|
212
|
+
edge_detect=True,
|
|
213
|
+
brightness=1.1,
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
converter = AsciiConverter(config)
|
|
217
|
+
frame = converter.convert_image("photo.jpg")
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Video Conversion & Playback
|
|
221
|
+
|
|
222
|
+
```python
|
|
223
|
+
from asciify import convert_video, play_video
|
|
224
|
+
|
|
225
|
+
# Convert video (local file or YouTube link) to MP4 animation with audio
|
|
226
|
+
convert_video(
|
|
227
|
+
input_path="https://www.youtube.com/watch?v=dQw4w9WgXcQ",
|
|
228
|
+
output_path="output_ascii.mp4",
|
|
229
|
+
width=120,
|
|
230
|
+
color_mode="color",
|
|
231
|
+
keep_audio=True,
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
# Convert video to GIF
|
|
235
|
+
convert_video("input.mp4", "output_ascii.gif", width=80, fps=12)
|
|
236
|
+
|
|
237
|
+
# Stream video or YouTube link directly in terminal
|
|
238
|
+
play_video("https://www.youtube.com/watch?v=dQw4w9WgXcQ", color_mode="cyan", loop=False)
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## ⚡ Performance Architecture
|
|
244
|
+
|
|
245
|
+
`asciify-graphic` is engineered for high throughput:
|
|
246
|
+
1. **Vectorized Character Mapping**: Grayscale luminance quantization and character lookups run in native C via NumPy arrays.
|
|
247
|
+
2. **Glyph Atlas Blitting**: Font glyph alpha masks are pre-rendered once into an atlas `(N, char_h, char_w, 1)`. Frame compositing operates via vectorized broadcast multiplication, achieving **~60+ FPS per CPU core** for HD frames.
|
|
248
|
+
3. **Run-Length Optimized ANSI**: Adjacent terminal characters sharing identical RGB colors are collapsed into single escape sequences, minimizing string overhead and maximizing terminal refresh rates.
|
|
249
|
+
4. **Self-Contained FFmpeg Muxing**: Direct H.264 video streaming and audio muxing without requiring external system package installations.
|
|
250
|
+
5. **Smart URL & YouTube Caching**: Direct images and YouTube streams are downloaded once to local cache with SHA-256 validation to avoid redundant downloads.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## 🧪 Testing
|
|
255
|
+
|
|
256
|
+
Run the test suite with `pytest`:
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
pytest -v
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
All 28 unit and integration tests verify image conversion, video rendering, audio muxing, glyph atlas rasterization, URL downloads, YouTube format merging, and CLI dispatch.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## 📄 License
|
|
267
|
+
|
|
268
|
+
MIT License. See [LICENSE](LICENSE) for details.
|