Skip to main content

A lightweight module to generate colorful ascii art from images

Project description

img2text

A lightweight module to generate colorful ascii art from images

To install img2text:

pip install img2text 

How To Use

Let's use the python logo as reference:

Python Logo

To generate an ascii image

from img2text import img_to_ascii

ascii_img = img_to_ascii('data/python.png', width=80)
print(ascii_img)

We obtain the following:

First Generated Image

Adding Color

We can customize this further by adding color (to be shown in the console):

from img2text import img_to_ascii

ascii_img = img_to_ascii('data/python.png', width=80, colorful=True)
print(ascii_img)

We obtain the following:

Second Generated Image

Customizing Output

We can reverse the intensity of the image by setting reverse to True

from img2text import img_to_ascii

ascii_img = img_to_ascii('data/python.png', width=80, colorful=True, reverse=True)
print(ascii_img)

We obtain the following:

Third Generated Image

We can get a slightly brighter image by adding the bright option which sets the characters to bold:

from img2text import img_to_ascii

ascii_img = img_to_ascii('data/python.png', width=80, colorful=True, reverse=True, bright=True)
print(ascii_img)

We obtain the following:

Fourth Generated Image

You can also change the character set by providing a custom string of characters that increase in intensity:

from img2text import img_to_ascii

chars = r" ░▒▓█"

ascii_img = img_to_ascii('data/python.png', width=80, colorful=True, bright=True, chars=chars)
print(ascii_img)

We obtain the following:

Fourth Generated Image

Additional Options

  • Customize the width and height by providing the number of columns/lines to use
  • Customize the aspect ratio by providing ar_coef coefficient. The default value is set to 2.4 but depending on the console you are using it might be interesting to try out values from [2, 3]
  • You can add a Background Color by setting bg_color to one of the following values:
    • BLACK
    • RED
    • GREEN
    • YELLOW
    • BLUE
    • MAGENTA
    • CYAN
    • WHITE

Project details


Download files

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

Source Distribution

img2text-0.0.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

img2text-0.0.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file img2text-0.0.2.tar.gz.

File metadata

  • Download URL: img2text-0.0.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for img2text-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e576615449e6e19f822e7fe71303b0ee7610abae94383a6f22267df5e4c55583
MD5 9ceb326c22b9e2d200d9cc38de69af20
BLAKE2b-256 d38dc7157ec183320ee7643538aaae65792269fa3fc6e5cbcb44382a3c0b8916

See more details on using hashes here.

File details

Details for the file img2text-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: img2text-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for img2text-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 29f52c8ab481fcb5547c3938edce270d8a11fbb52a228c80878f3f9b9742b188
MD5 73b50a537781f6ea793f215eba730dee
BLAKE2b-256 1bc28de14ef60940fd23d642b5384cd156fa8d3b4b3ce72bd835ea2bb57fe7dd

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