Skip to main content

A package which can convert videos, images, and gifs to ascii art!

Project description

To-Ascii PYPI Downloads

Converts videos, images, and gifs into ascii art!

[Example] [Example 2]

  • Works on most common image types
  • Works on most common video types
  • Works on gifs

How does it work?

Videos:

When the conversion process is started, the video file is opened up and went through frame by frame. Each frame is composed of a set of arrays like [[[r, g, b], [r, g, b]], [[r, g, b], [r, g, b]]], the software then goes through each frame and calculates the average brightness of each pixel, which is then used to get a value from a gradient of ascii characters. Then, at the end, a set of "pretty" frames are made, that list looks like ['frame', 'frame',..] with frame obviously being the ascii art for each frame. When .view() is called or the video is viewed, the software print()s out each frame and then time.sleep()s for a bit.

Images:

The process is virtually identical to the one above, except it doesn't need to do a multitude of frames/images, it only needs to convert one. When .view() is called it just displays the image.

Installation

Via pip:

python3 -m pip install to-ascii

Example Usage

CLI:

to-ascii -t filetype -f filename

Video / GIF:

from toascii import Video

v = Video('my_file.mp4', scale=.1, verbose=True)
v.convert()  # convert the frames into ascii
v.view()  # play the converted frames in the console

Image:

from toascii import Image

img = Image('my_image.png', scale=.1, verbose=True)  # load the image
img.convert()  # convert the image to ascii
img.view()  # view the final asciified image

Documentation

  • toascii.Video(filename='video.mp4', *, scale=1, w_stretch=2, gradient=Union[int, str], verbose=False)
    • Note: only filename can be a positional argument, the rest are kwargs.
    • Arguments:
      • filename the name of the file/video which is to be opened and processed
      • scale the amount/1 which the video dimensions are multiplied by
      • w_stretch the amount that the width dimension is multiplied by
      • gradient either an integer from the preset gradients, or a custom gradient Example: '#$a=+-., '
      • verbose whether or not to show extra information
    • Functions:
      • convert actually converts the video into ascii
      • view view the converted video

  • toascii.Image(filename='image.png', *, scale=1, w_stretch=2, gradient=Union[int, str], verbose=False)
    • Note: only filename can be a positional argument, the rest are kwargs.
    • Arguments:
      • filename the name of the file/image which is to be opened and processed
      • scale the amount/1 which the image dimensions are multiplied by
      • w_stretch the amount that the width dimension is multiplied by
      • gradient either an integer from the preset gradients, or a custom gradient Example: '#$a=+-., '
      • verbose whether or not to show extra information
    • Functions:
      • convert actually converts the image into ascii
      • view view the converted image

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

to-ascii-3.3.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

to_ascii-3.3.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file to-ascii-3.3.0.tar.gz.

File metadata

  • Download URL: to-ascii-3.3.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2

File hashes

Hashes for to-ascii-3.3.0.tar.gz
Algorithm Hash digest
SHA256 08179c6ecb8689d7b1f78ed7586e147f4cdd8d4393f3d04b9179fce1fd12c97e
MD5 6a3116b2be62c5f6b8f2e6835749754e
BLAKE2b-256 d06a30a2d0a06e90295cc2f0b64149d8caf2ff7a0317ecb9e3c1028268a84b41

See more details on using hashes here.

File details

Details for the file to_ascii-3.3.0-py3-none-any.whl.

File metadata

  • Download URL: to_ascii-3.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2

File hashes

Hashes for to_ascii-3.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5069c4281b994c57f515e35a3b8182164e37a220e4ca6f1e5eddd9fa0cafbdb
MD5 e8067e572356dc6b87561cb036b34ec7
BLAKE2b-256 5e985648fc24f5e114acc82dc38a1a71f27816be64a5ea53b5e6b3c931221199

See more details on using hashes here.

Supported by

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