Create Word Art From An Image Using Python

If you are a Python developer then you may be fully convinced that we can do very cool things using Python in a very easy way.

Today I’m going to show you a very beautiful usage of Python, in which we will see how we can generate a word art of any given image. You can pick an image of your pet, you can pick an image of natural scenery, you can pick an image of human, basically you can pick anything as your image.

Once the image is selected, it is just a matter of few lines of Python code.

Package

To generate word art we need to install a package named pywhatkit. If you are using pip to install your Python packages, then here is the syntax:

pip install pywhatkit

Code

Once the package is installed, you need to import the package and call the function named image_to_ascii_art(…). This function will take two parameters — first one is the image file path and second parameter is the name for output file.

Here are the two lines of code:

import pywhatkit
pywhatkit.image_to_ascii_art(“Wolf.png”,”MyArt”)

On execution of above lines, you will find that a new file named MyArt.txt is generated.

Sample Input Image and Output

Input image

Output image

Hope you enjoyed creating this word art. You can also watch this complete flow on my YouTube channel here.


Similar Articles