0

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).

enter image description here

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?

1 Answer 1

1

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')

Result

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.