Let’s add some text to an image:
NumPy cannot add text of its own. You need to use the Pillow
library
instead:
.. literalinclude:: memegen.py
For the code to run, you need a True-Type-Font (TTF). You can use your own or download arial.ttf.
To convert a Pillow Image to a Numpy array, use:
a = np.array(im)
and back:
im = Image.fromarray(a)
Add text to your own image to create a meme or inspirational image.