• Stars
    star
    1,139
  • Rank 40,788 (Top 0.9 %)
  • Language
    Python
  • Created about 6 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Convert any image into ASCII Art.

Convert Images into ASCII Art with the power of Python

Contents

What ASCIIFY is

ASCIIFY is a python script that takes in as input an image, and returns a text output that resembles the input image. In other words, it replicates an image with certain characters.

For example, when the following image of Octocat -

is passed as a parameter into ASCIIFY, the following output is observed -

....................................................................................................
....................................................................................................
.....................................####:...............####.......................................
.....................................#########################......................................
.....................................#########################......................................
.....................................########################.......................................
....................................###########################.....................................
...................................#############################....................................
...................................########?+?#######%++########....................................
...................................#####:::..::::::::::..::+####....................................
...................................####:::....::::::::.?..::####....................................
...................................####:::..?.::::::::?.?.::####....................................
...................................+###:::+??;::::::::???.::@###....................................
....................................###:::.??.::::::::.?..::###.....................................
.......................................###:::::::?::::::::###.......................................
........................................:####::::::::::@###.........................................
..................................###.......############............................................
..................................:,##.......@#######@..............................................
..................................:.##......###########.............................................
.....................................#:;....###########.............................................
......................................#@%#:S#####.#####@............................................
.......................................#######.##.######............................................
............................................##.##.######............................................
............................................##.##.######............................................
........................................::::##:##:######::::........................................
.....................................::::::###:##:###:###::::::.....................................
....................................,:::::::++##S::###++:::::::.....................................
.....................................:::::::++:++:++++++:::::::.....................................
.......................................:::::++:++:++++++:::::.......................................
..........................................::++:++:++++++::..........................................
..................................................,.................................................
....................................................................................................

How ASCIIFY works

ASCIIFY works in a rather simple and intuitive way. Here's the algorithm -

  • Resize the image to a standard dimension, while maintaining aspect ratio
  • Convert to grayscale (the reason for doing so is because characters are replaced based on their intensity)
  • Create list of special characters to replace pixels with
  • Classify and divide pixels into buckets or groups, based on their intensity
  • Replace all pixels in a bucket with the corresponding special character
  • Print the text into terminal or write into a file
  • Profit!

How to use ASCIIFY

  • Ensure you have the required dependency "PIL" for Python installed. (pip install pillow)
  • Clone the repo
  • Run the python script, and pass the image path as the parameter
  • The script will print the output in the terminal, and will also write into a file 'img.txt' in the same directory as the python script
  • Profit!

Future Plans

  • Alternatively support colored outputs by printing the text onto an image

Support Me

If you liked this, leave a star! ⭐

If you liked this and also liked my other work, be sure to follow me for more! 🙂

More Repositories

1

scoper

Fuzzy and semantic search for captioned YouTube videos.
Python
265
star
2

ducky

Chrome extension to overlay a (super adorable) rubber duck, as a virtual companion during rubber duck debugging.
JavaScript
82
star
3

code-faster

Sublime Text plugin for programming contests - loads codeforces problems right into your text editor with a single button.
Python
39
star
4

markov-sherlock-holmes-twitterbot

Markov model manually implemented that predicts words probabilistically based on historic data.
Python
6
star
5

A-Z-with-NLP

A complete walkthrough of standard NLP challenges.
Jupyter Notebook
6
star
6

lsb-steganography

Text encryption in images, using LSB Steganography. Designed for CSE4019 Image Processing Class.
Python
6
star
7

web-whatsapp-bot

A bot implemented using Selenium Webdriver in Python to gain exposure toward browser automation
Python
4
star
8

competitive-programming

My submissions to online judges
Python
4
star
9

click-me

To my followers, I've got an announcement for you.
3
star
10

Procedural-Generation

Code from my blog post on procedural generation.
Python
2
star
11

Light-me-up

Python. Arduino. Psychology. Pretty Lights.
Python
2
star
12

Resume

My accomplishments and credentials. 📄
1
star
13

two-pointer-algorithm

Supplementary code for my blog post on the two pointer algorithm.
Python
1
star
14

Guess-Who

Entity identification based on idiolectic text analysis
Python
1
star
15

i-love-xkcd

Application to scrape XKCD comic and share with a slack channel
Python
1
star
16

algorithm-implementations

A re-implementation of standard algorithms for practice.
Python
1
star