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.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

img2text-0.0.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: img2text-0.0.1.tar.gz
  • Upload date:
  • Size: 3.7 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.1.tar.gz
Algorithm Hash digest
SHA256 e0edd1ed7845c00b205265b09480b1d11233d98a201c39c436e0be79b6a10210
MD5 a96a56c535c71db6ac57c2d967ee95a2
BLAKE2b-256 fb6b4ed51977ebd2769b23d3d38b2079c7bb1756d7836ae005ee0bac0d7426a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: img2text-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 11ce498f96ad292639c6d5e4c1016a0345fe16eaf2d4071a5b445322a981f4ec
MD5 dbadcd7a23e6a477801780a326d76a54
BLAKE2b-256 2d48212676ae360e1cc22e7e5e4c9e313665a8a6c51abbc2f7f30ecfba6ab884

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