Skip to main content

Gitpod Ready-to-Code

PyPI version

Image2ASCII

img2ascii is a library written in python which can convert image or video files to ASCII

Option list:

  • -h or --help : To generate the help text
  • -m or --mode : Select the mode of operation -- t for text, i for image, v for video and w for webcam input
  • -c or --color : Optional parameter to select color mode. 0 - B/W, 1 - Grayscale and 2 - RGB. Default color mode is B/W
  • --fcolor : Optional parameter to set the text color in binary color mode. Default = white
  • --bcolor : Optional parameter to set the background color in binary color mode. Default = black
    INFO: For --fcolor and --bcolor, you can use color names - white, black, red, green, blue, yellow, cyan and magenta. To use other colors, hex codes for those colors must be supplied. Example - ffcc99.
  • -k or --kernel : Optional parameter to set the kernel size, default is 7px
  • -d or --density : Optional parameter to set the ASCII text density on image, default is 0.3 units; Range - (0,1) (exclusive)
  • -i or --ifile : Path to the input file for image and video modes
  • -o or --ofile : Path to the output file for image and video modes
  • -s or --cam_source : Camera to be used for webcam mode. Use 0,1,2,3... to select cameras connected to the PC. Default value is 0
  • -f or --fancy : Fancy mode :). (Color mode defaults to RGB)

Installation:

  • Direct install : - python3 -m pip install img2ascii
  • From Git :
    1. git clone https://github.com/gopaljigaur/img2ascii.git
    2. cd img2ascii
    3. python3 setup.py build
    4. python3 setup.py install

Usage :

  • For text : img2ascii.py -m t -i <inputfile> -o <outputfile> -k <kernel_size>[optional] -d <text_density>[optional]
  • For image : img2ascii.py -m i -c[color mode (optional)] --fcolor <text_color_hex>[optional] --bcolor <background_color_hex>[optional] -i <inputfile> -o <outputfile> -k <kernel_size>[optional] -d <text_density>[optional] -f <fancy_mode>[optional]
  • For video : img2ascii.py -m v -c[color mode (optional)] --fcolor <text_color_hex>[optional] --bcolor <background_color_hex>[optional] -i <inputfile> -o <outputfile> -k <kernel_size>[optional] -d <text_density>[optional] -f <fancy_mode>[optional]
  • For webcam : img2ascii.py -m w -c[color mode (optional)] --fcolor <text_color_hex>[optional] --bcolor <background_color_hex>[optional] -k <kernel_size>[optional] -d <text_density>[optional -s <source_camera (0,1,2...)>[optional] -f <fancy_mode>[optional]

Usage in python code:

  • For text : from img2ascii import text_gen
    then text_gen.generate_ascii_t(str inputfile, str outputfile, int kernel [o], float density [o])
  • For image : from img2ascii import image_gen
    then image_gen.generate_ascii_i(str inputfile, str outputfile, int color [o], int kernel [o], float density [o], bool fancy [o], tuple(int) fcolor [o], tuple(int) bcolor [o])
  • For video : from img2ascii import video_gen
    then video_gen.generate_ascii_v(str inputfile, str outputfile, int color [o], int kernel [o], float density [o], bool fancy [o], tuple(int) fcolor [o], tuple(int) bcolor [o])
  • For webcam : from img2ascii import image_gen
    then image_gen.generate_ascii_w(int color [o], int kernel [o], float density [o], int cam_source [o], str cam_name [o], bool fancy [o], tuple(int) fcolor [o], tuple(int) bcolor [o])

NOTE : Parameters followed by [o] are optional

Also, thanks to Andrea Schiavinato for pygrabber

Release files for img2ascii 3.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for img2ascii 3.0.7
File Interpreter ABI Platform
img2ascii-3.0.7-py3-none-any.whl Python 3 none any Details

Release files / img2ascii-3.0.7-py3-none-any.whl

Download URL img2ascii-3.0.7-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
353b7d874da60cd9afcd1101213e929287834ee4c2966d753091033ae0b5a512
BLAKE2b-256 checksum
How to use checksums
f1be5d034accaa8c66bdeb4b3c02a72d72a6065ba70a1988e49d6b1f49a60629
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1

Release history Release notifications | RSS feed

This release

3.0.7 This release

1 release file

3.0.6

1 release file

3.0.3

1 release file

3.0.2

1 release file

3.0.1

2 release files

3.0.0

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page