ascii-art-python 0.3.0__tar.gz → 1.0.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.
Files changed (19) hide show
  1. {ascii_art_python-0.3.0 → ascii_art_python-1.0.1}/LICENSE +21 -21
  2. {ascii_art_python-0.3.0/ascii_art_python.egg-info → ascii_art_python-1.0.1}/PKG-INFO +276 -265
  3. {ascii_art_python-0.3.0 → ascii_art_python-1.0.1}/README.md +242 -231
  4. ascii_art_python-1.0.1/ascii_art_python/__init__.py +10 -0
  5. ascii_art_python-0.3.0/ascii_art_python/new_school.py → ascii_art_python-1.0.1/ascii_art_python/ascii_base.py +394 -383
  6. ascii_art_python-1.0.1/ascii_art_python/full_mode.py +45 -0
  7. ascii_art_python-1.0.1/ascii_art_python/new_skool.py +26 -0
  8. ascii_art_python-1.0.1/ascii_art_python/old_skool.py +38 -0
  9. {ascii_art_python-0.3.0 → ascii_art_python-1.0.1/ascii_art_python.egg-info}/PKG-INFO +276 -265
  10. {ascii_art_python-0.3.0 → ascii_art_python-1.0.1}/ascii_art_python.egg-info/SOURCES.txt +4 -1
  11. {ascii_art_python-0.3.0 → ascii_art_python-1.0.1}/ascii_art_python.egg-info/requires.txt +1 -1
  12. {ascii_art_python-0.3.0 → ascii_art_python-1.0.1}/pyproject.toml +56 -56
  13. {ascii_art_python-0.3.0 → ascii_art_python-1.0.1}/setup.cfg +4 -4
  14. ascii_art_python-0.3.0/ascii_art_python/__init__.py +0 -8
  15. {ascii_art_python-0.3.0 → ascii_art_python-1.0.1}/MANIFEST.in +0 -0
  16. {ascii_art_python-0.3.0 → ascii_art_python-1.0.1}/ascii_art_python/assets/fonts/GoogleSansCode-Regular.ttf +0 -0
  17. {ascii_art_python-0.3.0 → ascii_art_python-1.0.1}/ascii_art_python/assets/fonts/KreativeSquareSM.ttf +0 -0
  18. {ascii_art_python-0.3.0 → ascii_art_python-1.0.1}/ascii_art_python.egg-info/dependency_links.txt +0 -0
  19. {ascii_art_python-0.3.0 → ascii_art_python-1.0.1}/ascii_art_python.egg-info/top_level.txt +0 -0
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Guillem Prieur
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.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Guillem Prieur
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.
@@ -1,265 +1,276 @@
1
- Metadata-Version: 2.4
2
- Name: ascii_art_python
3
- Version: 0.3.0
4
- Summary: A Python library and CLI tool for converting images and videos into ASCII art.
5
- Author-email: Guillem Prieur <prieurguillem38@gmail.com>
6
- Project-URL: Homepage, https://gitlab.pprriieeuurr.fr/guill_prieur/ascii-art-python
7
- Project-URL: Bug Tracker, https://gitlab.pprriieeuurr.fr/guill_prieur/ascii-art-python/-/issues
8
- Project-URL: Source Code, https://gitlab.pprriieeuurr.fr/guill_prieur/ascii-art-python
9
- Keywords: ascii,ascii-art,image-to-ascii,video-to-ascii,cli,terminal,terminal-graphics,generator,converter
10
- Classifier: Development Status :: 4 - Beta
11
- Classifier: Intended Audience :: Developers
12
- Classifier: Intended Audience :: End Users/Desktop
13
- Classifier: Topic :: Multimedia :: Graphics
14
- Classifier: Topic :: Multimedia :: Video
15
- Classifier: Topic :: Terminals
16
- Classifier: Environment :: Console
17
- Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3.9
19
- Classifier: Programming Language :: Python :: 3.10
20
- Classifier: Programming Language :: Python :: 3.11
21
- Classifier: Programming Language :: Python :: 3.12
22
- Classifier: License :: OSI Approved :: MIT License
23
- Classifier: Operating System :: OS Independent
24
- Requires-Python: >=3.9
25
- Description-Content-Type: text/markdown
26
- License-File: LICENSE
27
- Requires-Dist: pillow>=10.0.0
28
- Requires-Dist: tqdm>=4.65.0
29
- Requires-Dist: opencv-python-headless>=4.8.0
30
- Requires-Dist: moviepy>=1.0.3
31
- Requires-Dist: numpy>=1.24.0
32
- Requires-Dist: importlib_resources; python_version < "3.10"
33
- Dynamic: license-file
34
-
35
- # ASCII Art Python 🎨 - Convert Images & Videos to Terminal Graphics
36
-
37
- <div align="center">
38
-
39
- [![PyPI version](https://img.shields.io/pypi/v/ascii-art-python.svg)](https://pypi.org/project/ascii-art-python/)
40
- [![Python versions](https://img.shields.io/pypi/pyversions/ascii-art-python.svg)](https://pypi.org/project/ascii-art-python/)
41
- [![PyPI Downloads](https://img.shields.io/pypi/dm/ascii-art-python.svg)](https://pypi.org/project/ascii-art-python/)
42
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
43
-
44
- </div>
45
-
46
- This module provides advanced tools for converting classic images and videos into ASCII Art. It allows exporting the results as text files, new images, or new videos (with or without audio), and even playing videos directly in your terminal.
47
-
48
- ## 👀 Examples
49
-
50
- ```
51
- @@@@@@@@@@@@@@@@@@@@@@@@@@$&#{{{{{{{{{{{#&$@@@@@@@@@@@@@@@@@@@@@@@@@@@
52
- @@@@@@@@@@@@@@@@@@@@@&{*********{{{{{{{{{{{{{*{#@@@@@@@@@@@@@@@@@@@@@@
53
- @@@@@@@@@@@@@@@@@@@#**********{{{{{{{{{{{{{{{{{{{{$@@@@@@@@@@@@@@@@@@@
54
- @@@@@@@@@@@@@@@@@@#***{$@@@${*{{{{{{{{{{{{{{{{{{{{{&@@@@@@@@@@@@@@@@@@
55
- @@@@@@@@@@@@@@@@@@{***&@@@@@&*{{{{{{{{{{{{{{{{{{{{{{@@@@@@@@@@@@@@@@@@
56
- @@@@@@@@@@@@@@@@@@{***{$@@@${{{{{{{{{{{{{{{{{{{{{{{{@@@@@@@@@@@@@@@@@@
57
- @@@@@@@@@@@@@@@@@@{***{****{{{{{{{{{{{{{{{{{{{{{{{{{@@@@@@@@@@@@@@@@@@
58
- @@@@@@@@@@@@@@@@@@{*************{{{{{{{{{{{{{{{{{{{{@@@@@@@@@@@@@@@@@@
59
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#{{{{{{{{{{{{{{{{@@@@@@@@@@@@@@@@@@
60
- @@@@@@@@&#{{{{{{{{{{{{#############{{{{{{{{{{{{{{{{{@@;.:::.::=#@@@@@@
61
- @@@@${********{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{@@;.::::::::.=@@@@
62
- @@@{********{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{@@;.::::::::::.#@@
63
- @$********{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{@@;.::::::::::::#@
64
- @{******{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{@@;:::::::::::::;@
65
- &*****{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{&@$:::::::::::::::{
66
- {***{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{$@@=.::::::::::::::=
67
- {*{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{#$@@@=.::::::::::::::::
68
- {{{{{{{{{{{{{{{{{{{{{#$@@@@@@@@@@@@@@@@@@@@@@@@@@$=.::::::::::::::::::
69
- {{{{{{{{{{{{{{{{{{#@@@@&*=;;;;;;;;;;;;;;;;;;;;:..:::::::::::::::::::::
70
- {{{{{{{{{{{{{{{{{$@@#:........:::::::::::::::::::::::::::::::::::::::;
71
- #*{{{{{{{{{{{{{{$@@:........:::::::::::::::::::::::::::::::::::::::::(
72
- ${{{{{{{{{{{{{{{@@=.......:::::::::::::::::::::::::::::::::::::::::::&
73
- @#*{{{{{{{{{{{{{@$:.....::::::::::::::::::::::::::::::::::::::::::::*@
74
- @@{{{{{{{{{{{{{{@$:...:::::::::::::::::::::::::::::::::::::::::::::(@@
75
- @@@#*{{{{{{{{{{{@$:..:::::::::::::::::::::::::::::::::::::::::::::&@@@
76
- @@@@@#{{{{{{{{{{@$:.:::::::::::::::.:::::::::::::::::::::::::::($@@@@@
77
- @@@@@@@@@$$$$$$@@$:.:::::::::::::.=@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
78
- @@@@@@@@@@@@@@@@@$:.:::::::::::::::================*@@@@@@@@@@@@@@@@@@
79
- @@@@@@@@@@@@@@@@@$:::::::::::::::::::::::::::::::::=@@@@@@@@@@@@@@@@@@
80
- @@@@@@@@@@@@@@@@@$:::::::::::::::::::::::::({(:::::=@@@@@@@@@@@@@@@@@@
81
- @@@@@@@@@@@@@@@@@$:::::::::::::::::::::::(@@@@@(:::=@@@@@@@@@@@@@@@@@@
82
- @@@@@@@@@@@@@@@@@@;.:::::::::::::::::::::*@@@@@*:::=@@@@@@@@@@@@@@@@@@
83
- @@@@@@@@@@@@@@@@@@$::::::::::::::::::::::::*#*:::::#@@@@@@@@@@@@@@@@@@
84
- @@@@@@@@@@@@@@@@@@@@#:.::::::::::::::::::::::::::(@@@@@@@@@@@@@@@@@@@@
85
- @@@@@@@@@@@@@@@@@@@@@@@$*;::::::::::::::::::;(#@@@@@@@@@@@@@@@@@@@@@@@
86
- ```
87
-
88
- ![Example with the Nyan Cat video played in a terminal.](https://media0.giphy.com/media/v1.Y2lkPTc5MGI3NjExczN5eXo0cHRyMnRzZjVxOHI4NXN1cjc2ZzIyNHQ5cTkyMW8weHVhYSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/n0MEinoLqWEdHb129d/giphy.gif)
89
-
90
- ## 🔧 Features
91
-
92
- - Image to ASCII conversion
93
- - Video to ASCII animation with sound extraction
94
- - Play video directly in the terminal
95
- - Export to .txt, .png, .mp4, or .avi
96
-
97
- ## 📦 Installation
98
-
99
- You can install the module via pip:
100
-
101
- ```bash
102
- pip install ascii-art-python
103
- ```
104
-
105
- ## 🚀 Basic Usage
106
-
107
- To use the module, import it as follows:
108
-
109
- ```python
110
- import ascii_art_python as aap
111
- ```
112
-
113
- ## 📚 API Reference
114
-
115
- ### 1. Enumerations (Enums)
116
-
117
- These enumerations are used to define the export format or quality.
118
-
119
- `aap.new_school.ExportType` : Defines the file type when exporting an image or a video.
120
-
121
- - `aap.new_school.ExportType.IMAGE_FILE` (0): Exports as classic media (PNG image or MP4/AVI video).
122
-
123
- - `aap.new_school.ExportType.TEXT_FILE` (1): Exports as a plain text file (.txt or .vid.txt).
124
-
125
- `aap.new_school.VideoAscii.ExportQuality` : Defines the video compression quality (and the codec used) during export.
126
-
127
- - `aap.new_school.VideoAscii.ExportQuality.LOW` (0): Low quality (mp4v codec, .mp4 format).
128
-
129
- - `aap.new_school.VideoAscii.ExportQuality.HIGH` (1): High quality (FFV1 codec, .avi format).
130
-
131
- ### 2. Class `ImageAscii`
132
-
133
- Manages the conversion and manipulation of a still image into ASCII art.
134
-
135
- #### Constructors
136
-
137
- - `ImageAscii(image: PIL.Image.Image, max_size: int = 100_000, grid: list[str] = None)`
138
- - Description: Initializes an instance from an image object of the PIL/Pillow library.
139
- - Parameters:
140
- - `image`: The source image (Pillow).
141
- - `max_size`: The maximum size (number of pixels/characters) for the generated ASCII image.
142
- - `grid`: The list of characters to use (from darkest to lightest). If None, uses the default grid.
143
- - `ImageAscii.from_path(path: str, max_size: int = 10_000, grid: list[str] = None) -> ImageAscii`
144
- - Description: Convenient class method to instantiate directly from a file path.
145
- - `ImageAscii.from_string(content: str, font_size: int) -# ImageAscii`
146
- - Description: Convenient class method to instantiate directly from a character string.
147
-
148
- #### Methods
149
-
150
- - `to_list() -> list[str]`
151
- - Description: Converts the image into a list of strings (one string per line).
152
- - `to_image() -> PIL.Image.Image`
153
- - Description: Generates and returns a new Pillow image where the ASCII has been drawn using a specific font (KreativeSquare.ttf by default).
154
- - `export(filename: str = "mika_export", mode: ExportType = 0) -> None`
155
- - Description: Exports the generated image to the disk.
156
- - Parameters:
157
- - `filename`: The target file name (without extension).
158
- - `mode`: If ExportType.IMAGE_FILE, saves a .png. If `ExportType.TEXT_FILE`, saves a .txt.
159
-
160
- ### 3. Class VideoAscii
161
-
162
- Manages the conversion of a complete video into an ASCII animation.
163
-
164
- #### Constructor
165
-
166
- - `VideoAscii(path: str, fps: int = 10, frame_size: int = 12_000)`
167
- - Description: Prepares a video for ASCII processing.
168
- - Parameters:
169
- - `path`: Path to the source video.
170
- - `fps`: Target frames per second for the ASCII render (maximum framerate).
171
- - `frame_size`: Maximum size of each processed frame.
172
-
173
- #### Properties
174
-
175
- - fps -> float: Retrieves the native FPS of the source video.
176
- - size -> tuple[int, int]: Retrieves the dimensions (width, height) of the exported ASCII video.
177
-
178
- #### Methods
179
-
180
- - `export(filename: str = "mika_export", export_type: ExportType = 0, quality: ExportQuality = 0, sound: bool = False)`
181
- - Description: Exports the processed video.
182
- - Parameters:
183
- - `filename`: The target file name (without extension).
184
- - `export_type`: If `IMAGE_FILE`, generates a video. If `TEXT_FILE`, generates a custom animated text file (.vid.txt).
185
- - `quality`: Determines the generated video codec if the export is a video file.
186
- - `sound`: If True, extracts audio from the source and adds it to the final exported video.
187
- - `print_in_terminal() -> None`
188
- - Description: Plays the source video as an ASCII animation directly in the terminal console, respecting the framerate limit (max_fps).
189
-
190
- #### Static Methods
191
-
192
- - `VideoAscii.print_from_txt(txt: str)`
193
- - Description: Reads and displays in the terminal the content of a .vid.txt file previously generated by the export(export_type=ExportType.TEXT_FILE) method.
194
- - `VideoAscii.transfer_audio(source_video_path: str, target_video_path: str, output_path: str)`
195
- - Description: Extracts audio from `source_video_path` and applies it to `target_video_path` to generate `output_path`.
196
-
197
- ## 💡 Usage Examples
198
-
199
- ### Example 1: Convert and Export an Image
200
-
201
- ```python
202
- import ascii_art_python as aap
203
- # Create an object from a local file
204
- my_image = aap.new_school.ImageAscii.from_path("my_image.jpg", max_size=50_000)
205
-
206
- # Display ASCII in the console
207
- print(my_image)
208
-
209
- # Export the ASCII image in text format (.txt)
210
- my_image.export("text_result", mode=aap.new_school.ExportType.TEXT_FILE)
211
-
212
- # Export the ASCII image as a new readable image (.png)
213
- my_image.export("image_result", mode=aap.new_school.ExportType.IMAGE_FILE)
214
- ```
215
-
216
- ### Example 2: Play a Video in the Terminal
217
-
218
- ```python
219
- import ascii_art_python as aap
220
-
221
- my_video = aap.new_school.VideoAscii("my_video.mp4", fps=15, frame_size=8_000)
222
-
223
- # Play the animation live in the terminal
224
- my_video.print_in_terminal()
225
- ```
226
-
227
- ### Example 3: Convert a Video with Sound
228
-
229
- ```python
230
- import ascii_art_python as aap
231
-
232
- my_video = aap.new_school.VideoAscii("my_video.mp4", fps=24, frame_size=15_000)
233
-
234
- # Export the video with sound in MP4 format (Low Quality by default)
235
- my_video.export(
236
- filename="final_ascii_video",
237
- export_type=aap.new_school.ExportType.IMAGE_FILE,
238
- sound=True
239
- )
240
- ```
241
-
242
- ### Example 4: Convert a text and print it in the Terminal
243
-
244
- ```python
245
- import ascii_art_python as aap
246
-
247
- my_message = aap.new_school.ImageAscii.from_string(
248
- content = "Hello, World!",
249
- font_size = 15
250
- )
251
-
252
- print(my_message)
253
- ```
254
-
255
- ## ⚠️ Troubleshooting
256
-
257
- ### Important Note Regarding OpenCV Dependencies
258
-
259
- This project uses **`opencv-python-headless`** for background image processing.
260
-
261
- Please be aware that installing both `opencv-python` (the standard version with GUI features) and `opencv-python-headless` in the **same Python environment** will cause conflicts. Doing so may break OpenCV's display capabilities (such as `cv2.imshow()`) in your other projects.
262
-
263
- **To avoid any issues, it is highly recommended to:**
264
- - **Use a Virtual Environment:** Always install this project inside an isolated virtual environment (using `venv`, `conda`, or Docker).
265
- - **Check Existing Packages:** If you are installing globally and already have `opencv-python` installed, please remove it first (`pip uninstall opencv-python`) before installing this project's requirements.
1
+ Metadata-Version: 2.4
2
+ Name: ascii_art_python
3
+ Version: 1.0.1
4
+ Summary: A Python library and CLI tool for converting images and videos into ASCII art.
5
+ Author-email: Guillem Prieur <prieurguillem38@gmail.com>
6
+ Project-URL: Homepage, https://gitlab.pprriieeuurr.fr/guill_prieur/ascii-art-python
7
+ Project-URL: Bug Tracker, https://gitlab.pprriieeuurr.fr/guill_prieur/ascii-art-python/-/issues
8
+ Project-URL: Source Code, https://gitlab.pprriieeuurr.fr/guill_prieur/ascii-art-python
9
+ Keywords: ascii,ascii-art,image-to-ascii,video-to-ascii,cli,terminal,terminal-graphics,generator,converter
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: End Users/Desktop
13
+ Classifier: Topic :: Multimedia :: Graphics
14
+ Classifier: Topic :: Multimedia :: Video
15
+ Classifier: Topic :: Terminals
16
+ Classifier: Environment :: Console
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: License :: OSI Approved :: MIT License
23
+ Classifier: Operating System :: OS Independent
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: pillow>=10.0.0
28
+ Requires-Dist: tqdm>=4.65.0
29
+ Requires-Dist: opencv-python-headless>=4.8.0
30
+ Requires-Dist: moviepy>=2.0.0
31
+ Requires-Dist: numpy>=1.24.0
32
+ Requires-Dist: importlib_resources; python_version < "3.10"
33
+ Dynamic: license-file
34
+
35
+ # ASCII Art Python 🎨 - Convert Images & Videos to Terminal Graphics
36
+
37
+ <div align="center">
38
+
39
+ [![PyPI version](https://img.shields.io/pypi/v/ascii-art-python.svg)](https://pypi.org/project/ascii-art-python/)
40
+ [![Python versions](https://img.shields.io/pypi/pyversions/ascii-art-python.svg)](https://pypi.org/project/ascii-art-python/)
41
+ [![PyPI Downloads](https://img.shields.io/pypi/dm/ascii-art-python.svg)](https://pypi.org/project/ascii-art-python/)
42
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
43
+
44
+ </div>
45
+
46
+ This module provides advanced tools for converting classic images and videos into ASCII Art. It allows exporting the results as text files, new images, or new videos (with or without audio), and even playing videos directly in your terminal.
47
+
48
+ ## 👀 Examples
49
+
50
+ ```
51
+ @@@@@@@@@@@@@@@@@@@@@@@@@@$&#{{{{{{{{{{{#&$@@@@@@@@@@@@@@@@@@@@@@@@@@@
52
+ @@@@@@@@@@@@@@@@@@@@@&{*********{{{{{{{{{{{{{*{#@@@@@@@@@@@@@@@@@@@@@@
53
+ @@@@@@@@@@@@@@@@@@@#**********{{{{{{{{{{{{{{{{{{{{$@@@@@@@@@@@@@@@@@@@
54
+ @@@@@@@@@@@@@@@@@@#***{$@@@${*{{{{{{{{{{{{{{{{{{{{{&@@@@@@@@@@@@@@@@@@
55
+ @@@@@@@@@@@@@@@@@@{***&@@@@@&*{{{{{{{{{{{{{{{{{{{{{{@@@@@@@@@@@@@@@@@@
56
+ @@@@@@@@@@@@@@@@@@{***{$@@@${{{{{{{{{{{{{{{{{{{{{{{{@@@@@@@@@@@@@@@@@@
57
+ @@@@@@@@@@@@@@@@@@{***{****{{{{{{{{{{{{{{{{{{{{{{{{{@@@@@@@@@@@@@@@@@@
58
+ @@@@@@@@@@@@@@@@@@{*************{{{{{{{{{{{{{{{{{{{{@@@@@@@@@@@@@@@@@@
59
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#{{{{{{{{{{{{{{{{@@@@@@@@@@@@@@@@@@
60
+ @@@@@@@@&#{{{{{{{{{{{{#############{{{{{{{{{{{{{{{{{@@;.:::.::=#@@@@@@
61
+ @@@@${********{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{@@;.::::::::.=@@@@
62
+ @@@{********{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{@@;.::::::::::.#@@
63
+ @$********{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{@@;.::::::::::::#@
64
+ @{******{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{@@;:::::::::::::;@
65
+ &*****{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{&@$:::::::::::::::{
66
+ {***{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{$@@=.::::::::::::::=
67
+ {*{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{#$@@@=.::::::::::::::::
68
+ {{{{{{{{{{{{{{{{{{{{{#$@@@@@@@@@@@@@@@@@@@@@@@@@@$=.::::::::::::::::::
69
+ {{{{{{{{{{{{{{{{{{#@@@@&*=;;;;;;;;;;;;;;;;;;;;:..:::::::::::::::::::::
70
+ {{{{{{{{{{{{{{{{{$@@#:........:::::::::::::::::::::::::::::::::::::::;
71
+ #*{{{{{{{{{{{{{{$@@:........:::::::::::::::::::::::::::::::::::::::::(
72
+ ${{{{{{{{{{{{{{{@@=.......:::::::::::::::::::::::::::::::::::::::::::&
73
+ @#*{{{{{{{{{{{{{@$:.....::::::::::::::::::::::::::::::::::::::::::::*@
74
+ @@{{{{{{{{{{{{{{@$:...:::::::::::::::::::::::::::::::::::::::::::::(@@
75
+ @@@#*{{{{{{{{{{{@$:..:::::::::::::::::::::::::::::::::::::::::::::&@@@
76
+ @@@@@#{{{{{{{{{{@$:.:::::::::::::::.:::::::::::::::::::::::::::($@@@@@
77
+ @@@@@@@@@$$$$$$@@$:.:::::::::::::.=@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
78
+ @@@@@@@@@@@@@@@@@$:.:::::::::::::::================*@@@@@@@@@@@@@@@@@@
79
+ @@@@@@@@@@@@@@@@@$:::::::::::::::::::::::::::::::::=@@@@@@@@@@@@@@@@@@
80
+ @@@@@@@@@@@@@@@@@$:::::::::::::::::::::::::({(:::::=@@@@@@@@@@@@@@@@@@
81
+ @@@@@@@@@@@@@@@@@$:::::::::::::::::::::::(@@@@@(:::=@@@@@@@@@@@@@@@@@@
82
+ @@@@@@@@@@@@@@@@@@;.:::::::::::::::::::::*@@@@@*:::=@@@@@@@@@@@@@@@@@@
83
+ @@@@@@@@@@@@@@@@@@$::::::::::::::::::::::::*#*:::::#@@@@@@@@@@@@@@@@@@
84
+ @@@@@@@@@@@@@@@@@@@@#:.::::::::::::::::::::::::::(@@@@@@@@@@@@@@@@@@@@
85
+ @@@@@@@@@@@@@@@@@@@@@@@$*;::::::::::::::::::;(#@@@@@@@@@@@@@@@@@@@@@@@
86
+ ```
87
+
88
+ ![Example with the Nyan Cat video played in a terminal.](https://media0.giphy.com/media/v1.Y2lkPTc5MGI3NjExczN5eXo0cHRyMnRzZjVxOHI4NXN1cjc2ZzIyNHQ5cTkyMW8weHVhYSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/n0MEinoLqWEdHb129d/giphy.gif)
89
+
90
+ ## 🔧 Features
91
+
92
+ - 3 Unique rendering modes: Density (`new_skool`), Edges (`old_skool`), and Hybrid (`full_mode`).
93
+ - Image to ASCII conversion.
94
+ - Video to ASCII animation with sound extraction.
95
+ - Play video directly in the terminal.
96
+ - Export to `.txt`, `.png`, `.mp4`, or `.avi`.
97
+
98
+ ## 📦 Installation
99
+
100
+ You can install the module via pip:
101
+
102
+ ```bash
103
+ pip install ascii-art-python
104
+ ```
105
+
106
+ ## 🚀 Basic Usage
107
+
108
+ To use the module, import it as follows:
109
+
110
+ ```python
111
+ import ascii_art_python as aap
112
+ ```
113
+
114
+ ### 🎨 The 3 Rendering Modes
115
+
116
+ - The module is split into three main rendering modes. You can access the `Image` and `Video` classes from any of these modes depending on the artistic style you want:
117
+ - `aap.new_skool`: The classic density-based ASCII art mapping pixel brightness to a gradient of characters.
118
+ - `aap.old_skool`: An edge-detection based ASCII style using Canny/Sobel filters to draw contours with line characters (`-`, `/`, `\`, `|`).
119
+ - `aap.full_mode`: A hybrid approach combining edge-detection for sharp contours and density-based characters for shading.
120
+
121
+ ## 📚 API Reference
122
+
123
+ ### 1. Enumerations (Enums)
124
+
125
+ These enumerations are used to define the export format or quality. They are located in the base module.
126
+
127
+ `aap.ascii_base.ExportType` : Defines the file type when exporting an image or a video.
128
+
129
+ - `aap.ascii_base.ExportType.IMAGE_FILE` (0): Exports as classic media (PNG image or MP4/AVI video).
130
+
131
+ - `aap.ascii_base.ExportType.TEXT_FILE` (1): Exports as a plain text file (.txt or .vid.txt).
132
+
133
+ `aap.ascii_base.VideoAscii.ExportQuality` : Defines the video compression quality (and the codec used) during export.
134
+
135
+ - `aap.ascii_base.VideoAscii.ExportQuality.LOW` (0): Low quality (mp4v codec, .mp4 format).
136
+
137
+ - `aap.ascii_base.VideoAscii.ExportQuality.HIGH` (1): High quality (FFV1 codec, .avi format).
138
+
139
+ ### 2. Class `Image`
140
+
141
+ Manages the conversion and manipulation of a still image into ASCII art. Available in `new_skool`, `old_skool`, and `full_mode`.
142
+
143
+ #### Constructors
144
+
145
+ - `Image(image: PIL.Image.Image, max_size: int = 100_000, grid: list[str] = None)`
146
+ - Description: Initializes an instance from an image object of the PIL/Pillow library.
147
+ - Parameters:
148
+ - `image`: The source image (Pillow).
149
+ - `max_size`: The maximum size (number of pixels/characters) for the generated ASCII image.
150
+ - `grid`: The list of characters to use (from darkest to lightest). If None, uses the default grid. (Note: The `grid` parameter is not used in `old_skool` mode).
151
+ - `Image.from_path(path: str, max_size: int = 10_000, grid: list[str] = None) -> Image`
152
+ - Description: Convenient class method to instantiate directly from a file path.
153
+ - `Image.from_string(content: str, font_size: int) -> Image`
154
+ - Description: Convenient class method to instantiate directly from a character string.
155
+
156
+ #### Methods
157
+
158
+ - `to_list() -> list[str]`
159
+ - Description: Converts the image into a list of strings (one string per line).
160
+ - `to_image() -> PIL.Image.Image`
161
+ - Description: Generates and returns a new Pillow image where the ASCII has been drawn using a specific font (KreativeSquare.ttf by default).
162
+ - `export(filename: str = "mika_export", mode: ExportType = 0) -> None`
163
+ - Description: Exports the generated image to the disk.
164
+ - Parameters:
165
+ - `filename`: The target file name (without extension).
166
+ - `mode`: If ExportType.IMAGE_FILE, saves a .png. If `ExportType.TEXT_FILE`, saves a .txt.
167
+
168
+ ### 3. Class VideoAscii
169
+
170
+ Manages the conversion of a complete video into an ASCII animation. Available in `new_skool`, `old_skool`, and `full_mode`.
171
+
172
+ #### Constructor
173
+
174
+ - `VideoAscii(path: str, fps: int = 10, frame_size: int = 12_000)`
175
+ - Description: Prepares a video for ASCII processing.
176
+ - Parameters:
177
+ - `path`: Path to the source video.
178
+ - `frame_size`: Maximum size of each processed frame.
179
+ - `fps`: Target frames per second for the ASCII render (maximum framerate).
180
+
181
+ #### Properties
182
+
183
+ - fps -> float: Retrieves the native FPS of the source video.
184
+ - size -> tuple[int, int]: Retrieves the dimensions (width, height) of the exported ASCII video.
185
+
186
+ #### Methods
187
+
188
+ - `export(filename: str = "mika_export", export_type: ExportType = 0, quality: ExportQuality = 0, sound: bool = False)`
189
+ - Description: Exports the processed video.
190
+ - Parameters:
191
+ - `filename`: The target file name (without extension).
192
+ - `export_type`: If `IMAGE_FILE`, generates a video. If `TEXT_FILE`, generates a custom animated text file (.vid.txt).
193
+ - `quality`: Determines the generated video codec if the export is a video file.
194
+ - `sound`: If True, extracts audio from the source and adds it to the final exported video.
195
+ - `print_in_terminal() -> None`
196
+ - Description: Plays the source video as an ASCII animation directly in the terminal console, respecting the framerate limit (max_fps).
197
+
198
+ #### Static Methods
199
+
200
+ - `VideoAscii.print_from_txt(txt: str)` (Accessible via `aap.ascii_base.Video.print_from_txt`)
201
+ - Description: Reads and displays in the terminal the content of a .vid.txt file previously generated by the export(export_type=ExportType.TEXT_FILE) method.
202
+ - `VideoAscii.transfer_audio(source_video_path: str, target_video_path: str, output_path: str)` (Accessible via `aap.ascii_base.Video.transfer_audio`)
203
+ - Description: Extracts audio from `source_video_path` and applies it to `target_video_path` to generate `output_path`.
204
+
205
+ ## 💡 Usage Examples
206
+
207
+ ### Example 1: Convert and Export an Image (Full Mode)
208
+
209
+ ```python
210
+ import ascii_art_python as aap
211
+
212
+ # Create an object from a local file using the hybrid "full_mode"
213
+ my_image = aap.full_mode.Image.from_path("my_image.jpg", max_size=50_000)
214
+
215
+ # Display ASCII in the console
216
+ print(my_image)
217
+
218
+ # Export the ASCII image in text format (.txt)
219
+ my_image.export("text_result", mode=aap.ascii_base.ExportType.TEXT_FILE)
220
+
221
+ # Export the ASCII image as a new readable image (.png)
222
+ my_image.export("image_result", mode=aap.ascii_base.ExportType.IMAGE_FILE)
223
+ ```
224
+
225
+ ### Example 2: Play a Video in the Terminal (Old Skool Mode)
226
+
227
+ ```python
228
+ import ascii_art_python as aap
229
+
230
+ # Using "old_skool" for edge-detected contours
231
+ my_video = aap.old_skool.Video("my_video.mp4", frame_size=8_000, fps=15)
232
+
233
+ # Play the animation live in the terminal
234
+ my_video.print_in_terminal()
235
+ ```
236
+
237
+ ### Example 3: Convert a Video with Sound (New Skool Mode)
238
+
239
+ ```python
240
+ import ascii_art_python as aap
241
+
242
+ # Using classic "new_skool" density
243
+ my_video = aap.new_skool.Video("my_video.mp4", frame_size=15_000, fps=24)
244
+
245
+ # Export the video with sound in MP4 format (Low Quality by default)
246
+ my_video.export(
247
+ filename="final_ascii_video",
248
+ export_type=aap.ascii_base.ExportType.IMAGE_FILE,
249
+ sound=True
250
+ )
251
+ ```
252
+
253
+ ### Example 4: Convert a text and print it in the Terminal (New Skool Mode)
254
+
255
+ ```python
256
+ import ascii_art_python as aap
257
+
258
+ my_message = aap.new_skool.Image.from_string(
259
+ content="Hello, World!",
260
+ font_size=15
261
+ )
262
+
263
+ print(my_message)
264
+ ```
265
+
266
+ ## ⚠️ Troubleshooting
267
+
268
+ ### Important Note Regarding OpenCV Dependencies
269
+
270
+ This project uses **`opencv-python-headless`** for background image processing.
271
+
272
+ Please be aware that installing both `opencv-python` (the standard version with GUI features) and `opencv-python-headless` in the **same Python environment** will cause conflicts. Doing so may break OpenCV's display capabilities (such as `cv2.imshow()`) in your other projects.
273
+
274
+ **To avoid any issues, it is highly recommended to:**
275
+ - **Use a Virtual Environment:** Always install this project inside an isolated virtual environment (using `venv`, `conda`, or Docker).
276
+ - **Check Existing Packages:** If you are installing globally and already have `opencv-python` installed, please remove it first (`pip uninstall opencv-python`) before installing this project's requirements.