A python program to convert an image into an ascii image
This program allows you to convert images into ASCII art. It uses various parameters to control the conversion process, including image scaling, sharpness adjustment, brightness adjustment, character set, and more.
- Clone this repository to your local machine.
git clone https://www.github.com/ajratnam/image-to-ascii.git
- Activate the poetry environment.
poetry shell
- Install the dependencies.
poetry install
The documentation for the program can be read here.
Here are some examples of how to use the program:
from converter import image_to_ascii
print(image_to_ascii('images/angry_bird.jpg'))This converts the image to ASCII art and prints it to the console.

from converter import image_to_ascii, ascii_to_image
ascii_art = image_to_ascii('images/angry_bird.jpg')
ascii_art_image = ascii_to_image(ascii_art)
ascii_art_image.save('images/angry_bird_ascii.jpg')This saves the ASCII art to an image file on your computer.
from converter import image_to_ascii
print(image_to_ascii("images/angry_bird.jpg", size=(30, 30)))This resizes the ASCII art to look like 30x30 characters(but it is actually 60x30 pixels).

from converter import image_to_ascii
print(image_to_ascii("images/angry_bird.jpg", size=(30, 30), fix_scaling=False))This resizes the ASCII art to 30x30 characters.
from converter import image_to_ascii
print(image_to_ascii("images/angry_bird.jpg", scale=0.5))This resizes the ASCII art to 50% of the original size.

from converter import image_to_ascii
print(image_to_ascii("images/angry_bird.jpg", brightness=3))This increases the brightness of the ASCII art to 3 times the original.

from converter import image_to_ascii
print(image_to_ascii("images/angry_bird.jpg", brightness=0.2))This decreases the brightness of the ASCII art to 20% of the original.

from converter import image_to_ascii
print(image_to_ascii("images/angry_bird.jpg", sharpness=3))This increases the sharpness of the ASCII art to 3 times the original.

from converter import image_to_ascii
print(image_to_ascii("images/angry_bird.jpg", sharpness=0.2))This decreases the sharpness of the ASCII art to 20% of the original.

from converter import image_to_ascii
print(image_to_ascii("images/angry_bird.jpg", charset=' ░▒▓█'))Changes the characters used to generate the ASCII art.

from converter import image_to_ascii
print(image_to_ascii("images/angry_bird.jpg", colorful=True))Prints the ASCII art colorfully to the console.

This project is licensed under the MIT License.
Contributions are welcome! If you have any suggestions or improvements, feel free to create an issue or a pull request.
Install the additional development dependencies with poetry install --dev.
Run coverage test with python -m pytest --cov
