Image2ASCII
Converts images to ASCII, with a twist; it traces edges in the image and attempts to render them with suitably formed characters, à la good old handmade ASCII art:
It can also crop, output ANSI colour, adjust contrast/colour balance/brightness, invert, and other nice stuff, as well as render HTML.
Installation
From PyPI
# Minimal install:
pip install image2ascii
# Install with WSGI capabilities (see below):
pip install image2ascii[www]
From source
# You do use virtual envs, right?
python3 -m venv .venv
source .venv/bin/activate
# Minimal install:
pip install -e .
# Install with WSGI capabilities (see below):
pip install -e .[www]
Usage
CLI
Installation per instructions above creates an image2ascii command; run it for more info. Play around with various combinations of --invert, --negative, --contrast, --brightness, and --color-balance, until the results are to your liking. --color and --crop are also highly recommended.
WSGI
Image2ASCII can run as a simple WSGI application, courtesy of Flask. Just make sure you have installed it with the necessary extra requirements, either by running pip install image2ascii[www] or manually installing Flask and requests.
For this purpose, a fully working web implementation is also included. Not only does it leverage Image2ASCII's various features, it also enables drag-and-drop and pasting of images, and includes all sovereign state flags from Wikipedia for the user to choose from. A live version is (at the time of writing) available here.
Installation via pip will also create an image2ascii_testserver command with an optional port number argument (default is port 8000). Use it to fire up a basic web server on localhost and try it out. (Executing wsgi.py directly from the command line achieves the same thing.)
Here is a suggested (albeit untested) Supervisor setup:
/etc/supervisor/conf.d/image2ascii.ini:
[program:image2ascii]
directory = /path/to/image2ascii
command = /path/to/image2ascii/.venv/bin/uwsgi --ini config.ini
/path/to/image2ascii/config.ini:
[uwsgi]
module = image2ascii.wsgi:application
master = true
processes = 5
socket = /tmp/image2ascii.sock
chmod-socket = 666
vacuum = true
Configuration
The CLI looks for config files in these locations, by order of priority:
- Path set via
--configparameter ~/.image2asciidefaults.confin application directory (i.e. the directory whereconfig.pyis located)
The WSGI application looks for these config files, by order of priority:
web_defaults.confin application directory (a default one is included)~/.image2asciidefaults.confin application directory
Config files follow a normal INI file structure (key=value). For available keys, refer to config.py (more specifically: config.Config._fields).
Everything else
This project is totally in beta, and so its API should not be considered stable.
Shouts out to:
Metadata
Release files for image2ascii 0.6.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| image2ascii-0.6.2.tar.gz | 2.3 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| image2ascii-0.6.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.7 MB
Release files / image2ascii-0.6.2.tar.gz
| Download URL | image2ascii-0.6.2.tar.gz |
|---|---|
| Size | 2.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b792cbdf144cf8029080e7454a7149b1994bb27b59aa6bbc3d372ff20ccb16b
|
|
BLAKE2b-256 checksum How to use checksums |
65b4c917368093dce27164e83156d53921fbbbc0d0110ec196a4c1a2f0e314e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / image2ascii-0.6.2-py3-none-any.whl
| Download URL | image2ascii-0.6.2-py3-none-any.whl |
|---|---|
| Size | 2.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf82dafc6670442a8f61e7ff7fb2654b11be5131b2602fad87990eaf6e7d8945
|
|
BLAKE2b-256 checksum How to use checksums |
1307b89d71a864d9c42e35d532000e7a1d1fbe651e09fc6687af94cf65d292a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|