I want to make images in Python Pillow with text, insert the images into a Microsoft Word document, and have the font size in the image match the font size in the document. How do I make the font sizes match?
My Microsoft Word is set to insert images at 220 dpi, and I saw online that the default dpi for Pillow is 96, so I tried multiplying the font size in Pillow by 220/96, but the image font size still doesn't match the document font size.
Here's example code:
from PIL import Image, ImageDraw, ImageFont
fontSize = 12
## fontSize *= 220/96 ## adjust from PIL dpi to word dpi (didn't work)
font = ImageFont.truetype("TR Times New Roman Regular.ttf", size=fontSize)
im = Image.new("RGB", (100,100), "black")
draw = ImageDraw.Draw(im)
draw.text((10,40),"example text", fill="white", font = font)
im.show()
im.save("output.png")
Thanks!

