Registry / serialization / ascii-magic

ascii-magic

JSON →
library2.7.4pypypi✓ verified 35d ago

ASCII Magic is a Python package (v2.7.4) that converts images into ASCII art for terminals and HTML. It provides functionalities to generate ASCII art from local image files, URLs, or Pillow image objects. The library is actively maintained, with several minor releases in late 2025 and early 2026 that introduced new features and addressed compatibility issues.

serialization
Install & Compatibility
Where this runs
tested against v2.7.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.925 runs
installs and imports cleanly · install 0.0s · import 0.194s · 38.2MB
glibc
py 3.103.925 runs
installs and imports cleanly · install 2.2s · import 0.176s · 39MB
36MB installed
● package 36MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Since v2.0, the library was completely rewritten to be object-oriented. All core functionality is accessed via the `AsciiArt` class methods.

from ascii_magic import AsciiArt

This quickstart demonstrates how to load an image from a local file and display its ASCII art representation in the terminal. It also shows how to export the ASCII art to an HTML file. Replace `dummy_image.png` with your desired image file.

import os from ascii_magic import AsciiArt # Create a dummy image file for demonstration dummy_image_path = "dummy_image.png" with open(dummy_image_path, "wb") as f: # A minimal (invalid) PNG header to simulate a file f.write(b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15\xc4\x89\x00\x00\x00\x0cIDATx\xda\xed\xc1\x01\x01\x00\x00\x00\xc2\xa0\xf7Om\x00\x00\x00\x00IEND\xaeB`\x82') try: # Create AsciiArt object from an image file # Replace 'dummy_image.png' with your actual image path or a URL (AsciiArt.from_url) my_art = AsciiArt.from_image(dummy_image_path) # Print the ASCII art to the terminal my_art.to_terminal(columns=80) # Example of saving to an HTML file my_art.to_html_file('output.html', columns=120, full_color=True) print("ASCII art saved to output.html") except FileNotFoundError: print(f"Error: Image file '{dummy_image_path}' not found. Please provide a valid image path.") except Exception as e: print(f"An error occurred: {e}") finally: # Clean up the dummy image file if os.path.exists(dummy_image_path): os.remove(dummy_image_path)
ascii_magic --version
Debug
Known footguns
breakingVersion 2.0 introduced a complete rewrite of the library, transitioning to a full object-oriented programming (OOP) model. Code written for 1.x versions is no longer compatible with 2.x and above.
deprecatedSupport for DALL-E, Stable Diffusion, and Craiyon APIs was removed in v2.6 and v2.4 due to API availability changes. Functions like `from_dalle()` and `from_stable_diffusion()` are no longer available.
gotchaOn some Windows terminals, colors might not display correctly even if enabled. This is often due to the terminal's compatibility with ANSI escape codes.
gotchaWhen using `AsciiArt.from_url()`, network or server issues can cause `urllib.error.URLError` (or a generic `OSError`) if the image cannot be fetched.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
17 hits · last 30 days
bytedance
5
gptbot
4
ahrefsbot
4
script
1
googlebot
1
Resources