Skip to main content

Lightweight library for turning images to grid of ascii tokens

Project description

Summary

This is a lightweight library for turning images to grid of ascii tokens. Visual example:

Installation

The simplest and recommended way to install this package is to install it with PyPI:

pip install ascify

To install from source, do:

git clone https://github.com/theonekeyg/ascify.git && cd ascify
pip install .

Usage

Basic usage

The simplest usage, with only default parameters would look like this:

from ascify.grid import AsciiGrid

grid = AsciiGrid("./sample_image.png")
grid.start()
print(grid)

Configurability

Ascify framework is highly configurable, you can change output grid size, size of the moving window through the original image, output ascii tokens and logic behind choosing tokens for particular window (which i call renditions). All renditions take numpy.array of size (step, step, 3) as their first parameter, which represents the moving window at certain position on the image. Examples of implemented renditions can be found in ./ascify/renditions.py file. For instance, default rendition looks the following:

def default_rendition(img_slice, ascii_tokens):
    for char, threshold in ascii_tokens.items():
        if (img_slice.mean() >= threshold):
            return char

Besides of configuring rendition itself, you can configure ascii tokens, used for the output ascii grid. The tokens are passed directly to the rendition and don't participate in any other part of ascify, so the format of ascii tokens depends only on the logic of corresponding rendition used with it.

However, if you use one of the default renditions, the expected tokens format is object with implemented __getitem__ method, keys to which represens tokens themselves, and values represent threshold values. The default token dictonary looks the following:

default_tokens = {
    "@": 200,
    "#": 155,
    "&": 100,
    "*": 50,
    ".": 0
}

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ascify-1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

ascify-1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file ascify-1.0.tar.gz.

File metadata

  • Download URL: ascify-1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for ascify-1.0.tar.gz
Algorithm Hash digest
SHA256 d2733243e9bddfa3551158ffe4f7bd99897e23d5e492f28d0bd95987046a15a9
MD5 9f72890cab12020e73f6910fe58f1bdc
BLAKE2b-256 2a307443b0a418564d7aea138196f8fdadbf5f1cc4eb2bcf07469dd1519ea0cc

See more details on using hashes here.

File details

Details for the file ascify-1.0-py3-none-any.whl.

File metadata

  • Download URL: ascify-1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for ascify-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 842380fd61e7de499fa55fd3fdebb831417dbcff7291bd4978615236729d647e
MD5 62ee9a8ad12809d8df5014672e30c3a7
BLAKE2b-256 a2d73bf3bc34ba05a849cbba52ac09ab60d50b3512fe9d801d64faf7f16e28b9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page