背景
そんなにない
作業
- fontファイルの場所を調べる
$ fc-match -f "%{file}\n" FreeMono
/System/Library/Fonts/ヒラギノ丸ゴ ProN W4.ttc
- 画像作る
from PIL import Image, ImageDraw, ImageFont
font = ImageFont.truetype("/System/Library/Fonts/ヒラギノ丸ゴ ProN W4.ttc", size=60)
def make_image(n):
im = Image.new("RGB",(300,100),"blue")
draw = ImageDraw.Draw(im)# im上のImageDrawインスタンスを作る
draw.text((10,20), f"自由記述欄{n}", font=font)
im.save(f"./freetext{n}.jpg")
for i in range(0,50):
make_image(i)
- jupyter notebookで表示したかったら
from IPython.display import Image, display_png
display_png(Image('./name1.jpg'))