Image to Half-block ANSI art with IRC color codes.
Project description
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 -nuses nearest neighbor to resize the image. (useful if antialiasing makes the output look bad)--posterize -puses 4-bit posterization on the image. (useful if the image has a lot of different colors)--legacy-palette -luses 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file img2hbirc-1.0.1.tar.gz.
File metadata
- Download URL: img2hbirc-1.0.1.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f03f3e02b2269e637d5c99a834be7ae21ca7a49f138b92560a6749f7564426de
|
|
| MD5 |
37dd352a292e52d1513635f7598ca349
|
|
| BLAKE2b-256 |
6cad62c46b04b5475cb91754b382a0435ac88d9d865f1c4349ce5d6630542fb5
|
File details
Details for the file img2hbirc-1.0.1-py3-none-any.whl.
File metadata
- Download URL: img2hbirc-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11d20b3b4025863d73962ece67c8a97e9a4d2211084bd5dbd70473c39566a159
|
|
| MD5 |
be719cd139162e8d44313ae3efbdf629
|
|
| BLAKE2b-256 |
e086b86e033e5bb803ab7998214f06d01b677a083946ea2bedac7412714c4b23
|