This Python script converts an image into ASCII art. It resizes the input image, converts it to grayscale, and then maps the pixel values to ASCII characters to create an ASCII representation of the image.
- Python 3.x
- Pillow (PIL) library (
pip install Pillow
)
-
Clone this repository or download the
main.py
andfunctions.py
files. -
Place the image you want to convert into ASCII art in the same directory as
main.py
. Make sure to specify the image file path in themain.py
script. -
Run the script by executing
main.py
:python main.py
-
The script will prompt you to enter the name of the output text file (include the ".txt" extension). This is where the ASCII art will be saved.
-
Once the script finishes processing, you will find the ASCII art in the specified text file.
You can customize the appearance of the generated ASCII art by modifying the ASCII_CHARS
variable in the functions.py
script. You can replace the characters in ASCII_CHARS
with your preferred characters to achieve different visual effects.
python
ASCII_CHARS = "@%#*-+=:. "
Additionally, you can change the width of the generated ASCII art by modifying the new_width
parameter in the main
function in main.py
. A smaller new_width
value will result in a more detailed but larger ASCII art image.