| name | make-ascii |
| description | Make ASCII art — a big text banner/figlet, an image converted to ASCII, or a boxed/framed message. Use when the user wants a banner, ASCII logo, text-as-art, "turn this image into ASCII", or terminal eye-candy. Output prints in the terminal or saves to a .txt. |
| version | 1.0.0 |
Make ASCII art
Three jobs, three approaches. Pick by what the user asked.
1. Text banner (the common one) — pyfiglet
pyfiglet is a tiny pure-Python pip dep (no native libs). Install if missing,
then render. Don't write a file unless asked — print it so it shows in chat.
import pyfiglet
print(pyfiglet.figlet_format("HEARTH", font="slant"))
Good fonts: standard, slant, big, banner3-D, small, block, doom.
If pyfiglet truly isn't available (frozen build without it), fall back to
approach 3 (generate the letters yourself from a block-character palette).
2. Image → ASCII — Pillow (bundled)
Downscale, grayscale, map brightness to a character ramp (dark→light). Keep
width ≤ ~100 cols so it doesn't wrap. Correct for the ~2:1 char aspect by
halving the row count.
from PIL import Image
RAMP = "@%#*+=-:. "
img = Image.open("in.png").convert("L")
W = 90
w, h = img.size
H = max(1, int(W * h / w / 2))
img = img.resize((W, H))
px = img.getdata()
out = "\n".join(
"".join(RAMP[min(len(RAMP) - 1, p * len(RAMP) // 256)] for p in px[r*W:(r+1)*W])
for r in range(H)
)
print(out)
Invert the ramp (RAMP[::-1]) for a dark terminal vs light paper.
3. Generate-it-yourself fallback (zero deps)
When no library is available, build the art directly: compose letters from a
block palette (█ ▓ ▒ ░), draw a simple shape, or hand-build a small banner
row by row. For boxed text, frame it yourself:
def box(text):
lines = text.splitlines() or [""]
w = max(len(s) for s in lines)
top = "╭" + "─" * (w + 2) + "╮"
mid = "\n".join(f"│ {s.ljust(w)} │" for s in lines)
return f"{top}\n{mid}\n╰" + "─" * (w + 2) + "╯"
print(box("local-first AI"))
Hard rules
- Default to PRINTING the art (so it lands in chat); only write a
.txt if the
user wants the file.
- Keep width ≤ ~100 columns or it wraps and turns to mush.
- In the packaged app, don't
pip install — use the bundled libs or the
zero-dep fallback (approach 3).
- No "generated by" footer.