Post

Converting Images to ASCII

AIRATS

ASCII Image Convertor - How to install

Python

A simple Flask web app and command-line tool to generate ASCII art from an image URL or locally.

Both Web and Command Line usage

Turn any image locally or remotely into ASCII characters.

This project can be found on github here ascii art generator

Installation

Docker

1
docker pull bigsk1/airats:latest

or Build docker image in project root with Dockerfile

Clone the repo then

1
cd airats
1
docker build -t <your_image_name> .
1
docker run -d -p 5000:5000 <your_image_name>

Linux

Linux

  1. Clone the repo
1
git clone https://github.com/bigsk1/airats.git
1
cd airats
  1. (Optional) Create a virtual environment and activate it:
1
2
3
python3 -m venv venv

source venv/bin/activate
  1. Install the required Python packages:
1
pip install -r requirements.txt

Ubuntu 22.04+

Ubuntu

If you don’t want the virtual environment just make sure you have installed

1
sudo apt install python3 && sudo apt install python3-pip && sudo apt install python3-flask && python3 -m pip install Pillow && python3 -m pip install requests && python3 -m pip install gunicorn

run with python3 app.py in the airats folder

1
python3 app.py

Open a web browser and visit http://localhost:5000 to access the app.

Devcontainer VScode

Open in devcontainer and run! Find on localhost:5000

Windows 64bit install

Windows 11

Download .exe from releases here: https://github.com/bigsk1/airats/releases/tag/v1.0

You will most likely get a warning when trying to launch because it is not a signed .exe this is normal.

(optional) build your own by cloning the win64 branch here:

1
git clone --single-branch --branch win64 https://github.com/bigsk1/airats.git

see the requirements.txt for what dependencies are needed

Usage

Linux

Web Interface virtual environment in Python

  1. Run the Flask app (optional):
1
export FLASK_APP=app.py
1
flask run --host=0.0.0.0
  1. Open a web browser and visit http://localhost:5000 to access the app.

  2. Enter an image URL and width, then click “Generate ASCII Art” to see the result.

Command Line

Run any of the following commands from the airats directory:

python3 Main.py [-w WIDTH] [-ht HEIGHT]

Image size can be changed as needed

You can also run an image you have locally using:

python3 Main.py your_image.jpg -w 150 -ht 50

or

python3 Main.py https://your-image-url.jpeg -w 150 -ht 50

1
python3 Main.py images/rat.jpg -w 50 -ht 25

Output image to a file

1
python3 Main.py images/rat.jpg -w 80 -o output.txt

Supports

1
2
3
4
5
6
7
JPEG: .jpg, .jpeg
PNG: .png
GIF: .gif
BMP: .bmp
TIFF: .tif, .tiff
ICO: .ico
WebP: .webp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
                                 
                    `,^.`:l!<;,^'   .I, 
                   !-})}rcYCQLYzvt(]?[{; 
                  "+<+}}{ruYQQQ0QJvft?--` 
                 ir1_-)jrzvucccJZwQvnj?}(, 
               .-CZJf[}rcnuzLu/tjnzvrYYcYtl 
              .1QQCL0XcnrxuO#pCjf/(|fcpXYCx, 
              ]CLXcccXJYJJXzcrttt({[{|/vLQL/^ 
             +JLcrrnvYLCL0QLJCzt)]?[}}-)COLJ}`
            !XZQcjrvXYCQQOO0QJu(}]?{?]?+zO0Lc> 
           `tL00XnjncvcczXXXvf/|{[])()[]zLCXX{
           "rYYJYznxnvczzvuuuj({}]??][)uJCXvct'
           ,jXXYzcvnnvzXJJJYYzvf/|fnzYCQYYzuvn^
           .~ncccunuvcXJJXXYJ0mOqZZ00QO0JzvuvvI
            '?xrrjrzOZJvcvXQOdkhadmQLLLLCznxczI
              ~jrjt{)vQcvvut){(c0ZOQLLQQCcnuXX,
   ^l>+]{){]_!,l[/)<!!]ncu1__<]tuXCLQOZQYcvXJu'
 "+{jj|)fxuzQ0Qzxnx]!!i]cvurftuczCL0OOLJYXYJCt 
^[n/;.    .^!]rCwqQz|?{}cJLOOZZmpwmmO0QCYYCCC~
`-/[^          '!1uQZ0CQOZmpdppkkbkpmOLCLOZOt'
 ^_(]~!,^````^""`":~(Jdhao*#*o#MMMhZQC0mmLvj, 
   :~?}}}1)/nXzuvC0qdh#W8#abdpwmOLXXvYYvt-!I'
      .^":;l!!l!i+-{(/tjf}???-}{1?]1(/{?<!:,'
                              ..            

LICENSE

This project is licensed under MIT License.

This post is licensed under CC BY 4.0 by the author.