Reputation: 301
I have a couple of strings that I want to save as a BitMap Image of resolution 264*176 for displaying on an E-ink screen(because apparently eInk displays can't show text horizontally).
Please note that the blue background is only to show the dimensions of the image. The actual background will be white.
I've tried PIL without success. Can someone suggest any approach in Python3?
Upvotes: 0
Views: 459
Reputation: 547
Here is a PIL
example
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
img = Image.new('RGB', (264, 176), color = (255, 255, 255))
font_path = '/usr/share/fonts/truetype/ubuntu/UbuntuMono-R.ttf'
font = ImageFont.truetype(font_path, 20)
draw = ImageDraw.Draw(img)
draw.text((15, 15), 'Is it your text?', font=font, fill=(0, 0, 0))
img.save('img_with_text.bmp', 'bmp')
Upvotes: 1