Image to Half-block ANSI art with 256-color XTerm codes.
Find a file
swee a5cf794a26
All checks were successful
Upload Python Package / deploy (release) Successful in 21s
Bump version for docs update
2025-11-08 18:38:20 -08:00
.forgejo/workflows add 2025-11-08 18:21:30 -08:00
img2hbterm add 2025-11-08 18:21:30 -08:00
.gitignore Initial commit 2025-11-08 13:04:26 -08:00
LICENSE Initial commit 2025-11-08 13:04:26 -08:00
pyproject.toml Bump version for docs update 2025-11-08 18:38:20 -08:00
README.md Docs 2025-11-08 18:35:38 -08:00

img2hbterm

Image to Half-block ANSI art with 256-color XTerm codes.

Installation

As a CLI app

pipx install img2hbterm

As a module

pip install img2hbterm

CLI Usage

Simply convert using

img2hbterm image.png

Flags:

  • --nearest -n uses nearest neighbor to resize the image. (useful if antialiasing makes the output look too blurry)
  • --true-color -t uses True Color instead of XTerm 256-color. (less term support)
  • --width <int> -s <int> set the width of the image. (default: 128)

Module usage

from img2hbterm import convert
from io import BytesIO

print( convert("path") )

# The path can be anything Pillow supports, so BytesIO works as well
print( convert(BytesIO(b"....")) )

# With all the default values included
print(
    convert(
        "path",
        nearest=False,
        true=False, # Not to be confused with the boolean True
        size=128
    )
)

# Works the same way the CLI does, I don't need to document the parameters again.