Convert images into ascii art
Python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
img2text
samples
.gitignore
LICENSE
README.md
img2text.py

README.md

Image to Text

Convert images into ASCII art. This script has been tested with Python 2.7.

Requirements

This script requires:

  • Python 2.x (tested with 2.7)
  • Pillow
  • ArgumentParser

Dependencies can be installed using Pip. To install Pip on Ubuntu, run this command:

sudo apt install -y python-pip
sudo -H pip install -U pip --upgrade pip

Install setup-tools using pip:

sudo -H pip install -U pip Pillow ArgumentParser

Example usage

$ python img2text.py samples/bird.png --inverted
                                                             ▒▒
                                                           ░▓▓▓
                                                         ░▓▓▓▓▓
                                                       ░▓▓▓▓▓▓▒
                                                     ░▓▓▓▓▓▓▓▒░▒▒
                                                   ░▓▓▓▓▓▓▓▓▓▓▓▓▓
                                                 ░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒
                                               ░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒
                                             ░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒░
                                           ░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒
                                         ░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░
                                       ░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░
                                     ░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░
                                   ░▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░
             ░░▒▒▒▒▒░░            ▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
           ░▒▒▒▒▒▒▒▒▒▒▒▒▒░      ░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒
          ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░  ▒▓▓▓▓▓▓▓▒▒░░░░░░░░░░░░░░░░░░░░
          ▒▒▒▒▒▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▒░░░░▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒░
         ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
   ░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒
         ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒░░
          ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒░░
          ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒
           ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░
            ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░▒▒░
            ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒░░
             ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒
              ▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
               ▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒
               ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░
                ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒░░
                 ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ░▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒
                  ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░ ░░░▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒░▒▒░░
                   ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░░░░░▒▒░░ ░░░
                    ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░▒▒▒▒▒░
                     ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░
                       ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░
                         ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░▒▓▓▒▒▒░░
                           ░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░       ░▓▓▓▒▒▒░░
                               ░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░             ░▒▓▓▓▒▒▒▒░
                                                                  ▒▓▓▓▓▒▒▒▒░░
                                                                   ░▓▓▓▓▒▒▒▒▒░░
                                                                     ▒▓▓▓▓▒▒▒▒▒▒░
                                                                      ░▓▓▓▓▓▒▒▒▒▒▒░░
                                                                       ░▒▓▓▓▓▓▒▒▒▒▒▒
                                                                         ▒▓▓▓▓▓▒░
                                                                          ░░▒▓▓▓▒