↓ Pythonのプログラムを実行して、まさにこんな感じの画像ファイルを出力します。
2020年の現在においては、Pillowというライブラリがデファクトのようです。
hoge$ pip3 list ... Pillow 7.1.2 ...
お作法のハンズオンとしては、次が最小例となっていて分かりやすいと思います。
https://pillow.readthedocs.io/en/stable/reference/ImageDraw.html#example-draw-partial-opacity-text
上記例は下地になる画像を用意する方式なので、ここでは、さらにシンプルに、白紙の画像オブジェクトを新たにnewするところからの例としました。
↓
「 Python Pillow テキスト埋め込み画像」というピンクの文字を600 x 200 画像中心あたりにフォントサイズ42 で出力するPython プログラム例
from PIL import Image,ImageDraw,ImageFont def textImage(text, w, h, outputFile, font_size): #from matplotlib import font_manager #font_manager.findSystemFonts() # これで得られるもののうち、日本語フォントを指定する font_path = "ヒラギノ丸ゴ ProN W4.ttc" font_color = (255, 100, 100) bg_color = (255, 255, 255) font = ImageFont.truetype(font_path, font_size) img = Image.new(mode="RGB", size=(w,h), color=bg_color) d = ImageDraw.Draw(img) tw, th = d.textsize(text=text,font=font) d.text( xy=((w-tw)/2, (h-th)/2), # 文字サイズなどを考慮しておおよそ、文字が画像の真ん中になるように計算 text=text, font=font, fill=font_color) img.save(outputFile) text = "Python Pillow\nテキスト埋め込み画像" w, h = 600, 200 outputFile = '画像.png' font_size = 42 textImage(text, w, h, outputFile, font_size)