Simple command line that can take an input image and generator ascii-art from the image. Check this folder for couple example outputs. Making terminal characters smaller will improve output quality significantly.
Special thanks to Xander Gouws and his youtube video for inspiring me to create this project. Link To Video
Usage:
./cascii.exe path/to/image.png -other [value] --flagsTo build:
# Regular build
make
# build with clang (with optimzations on)
make clang
# compiled with optimizations
make releaseBuild Requirements:
- GCC or CLANG version that supports C99
- GNU Make
-
-mwmaximum width (Default terminal width or 96 characters) -
-mhmaximum height (Default terminal height or 64 characters) -
-setSobel edge detect threshold (DEFAULT: 67.0) (yes I know this feels like a joke but it works better than I expected) -
-crCharacter Ratio (Default 2.0) -
-baBrighten image amount (Default 1.0 -> Doesn't brighten) Note that any value over 2.0 may result in overly bright images -
--usebwoutput with no color (Default OFF) -
-cUse custom charcters for brightness in ascending order (Default: " .-=+*x#$&X@") Note that you can wrap "" around your input to include the whitespace character -
-oOutput to ASCII to file (DEFAULT OFF) -
-rRead outputted file (Slightly different usage ->./cascii.exe -r file_to_read.txt)
Note that if you use output on a colored image without setting the --usebw flag you may need to use a terminal viewer to view the image properly. The color is output using Ansi escape sequences. However, if you do use the flag --usebw you may view the outputted file with a regular text viewer.
# viewing outputted image
./cascii.exe lightning.jpg -o lightning.txt
# use cat
cat lightning.txt
# use less to view
less -R lightning.txt
# or just use cascii to read it
./cascii.exe -r lightning
# example with --usebw flag
./cascii.exe lightning.jpg -o lightning-normal.txt --usebw
# use any normal text editor to view
nvim lightning-normal.txt
# or you can open with notepad
notepad++ lightning-normal.txtExample use cases
# use default paramters for everything
./cascii.exe lightning.jpg
# Dont brighten image and effectively turn off the sobel threshold
./cascii.exe lightning.jpg -ba 1 -set 255.0
# produce black and white output
./cascii.exe lightning.jpg --usebw
# Output to a file
./cascii.exe lightning.jpg -o lightning.txt
# Using custom characters for an image using whitespace, a, b and E
./cascii.exe images/imposter.jpg -c " abE" - First loads an image using stb image
- Resizes image to match given parameters or the terminal height and width while accounting for the character ratio in terminals (typically 1 to 2)
- Does an Image convolution across the given image using a sobel Kernel to give sharper edges
- Uses luminosity for the sobel threshold and outputs | \ / _ depending on which direction the sobel is
- Use Ansi Escape codes to output color to the terminal


