img2ascii is a library written in python which can convert image or video files to ASCII
Option list:
-hor--help: To generate the help text-mor--mode: Select the mode of operation --tfor text,ifor image,vfor video andwfor webcam input-cor--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--fcolorand--bcolor, you can use color names -white,black,red,green,blue,yellow,cyanandmagenta. To use other colors, hex codes for those colors must be supplied. Example -ffcc99.-kor--kernel: Optional parameter to set the kernel size, default is 7px-dor--density: Optional parameter to set the ASCII text density on image, default is 0.3 units; Range - (0,1) (exclusive)-ior--ifile: Path to the input file for image and video modes-oor--ofile: Path to the output file for image and video modes-sor--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-for--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
thentext_gen.generate_ascii_t(str inputfile, str outputfile, int kernel [o], float density [o]) - For image :
from img2ascii import image_gen
thenimage_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
thenvideo_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
thenimage_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