Skip to main content

img2hbirc

Image to Half-block ANSI art with IRC color codes.

Installation

As a CLI app

pipx install img2hbirc

As a module

pip install img2hbirc

CLI Usage

Simply convert using

img2hbirc image.png

Output will look weird in terminal, so you can also put it in a file

img2hbirc -o image.txt image.png

Then you can upload it so an IRC bot can output it.

Flags:

  • --nearest -n uses nearest neighbor to resize the image. (useful if antialiasing makes the output look bad)
  • --posterize -p uses 4-bit posterization on the image. (useful if the image has a lot of different colors)
  • --legacy-palette -l uses the legacy 16-color mIRC color palette instead of the 84 other colors.
  • --width <int> -s <int> set the width of the image (default: 64), a high number might cause the IRC network to truncate your message.

Module usage

Convert RGB color to IRC control code

from img2hbirc import rgb2irc

# Regular way
print( rgb2irc(255, 0, 0) )

# mIRC palette
print( rgb2irc(255, 0, 0, legacy=True) )

You only get the color number as a string, so you have to embed it like

f"\x03{rgb2irc(255, 0, 0)}This text is red!\x01"

Convert Image

from img2hbirc 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,
        post=False,
        legacy=False,
        size=64
    )
)

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

Metadata

Release files for img2hbirc 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for img2hbirc 1.0.1
File Size Uploaded
img2hbirc-1.0.1.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for img2hbirc 1.0.1
File Interpreter ABI Platform
img2hbirc-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.0 kB

Release files / img2hbirc-1.0.1.tar.gz

Download URL img2hbirc-1.0.1.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f03f3e02b2269e637d5c99a834be7ae21ca7a49f138b92560a6749f7564426de
BLAKE2b-256 checksum
How to use checksums
6cad62c46b04b5475cb91754b382a0435ac88d9d865f1c4349ce5d6630542fb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.24

Release files / img2hbirc-1.0.1-py3-none-any.whl

Download URL img2hbirc-1.0.1-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11d20b3b4025863d73962ece67c8a97e9a4d2211084bd5dbd70473c39566a159
BLAKE2b-256 checksum
How to use checksums
e086b86e033e5bb803ab7998214f06d01b677a083946ea2bedac7412714c4b23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.24

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page