-1

I'm trying to convert text into bitmap, but not bitmap of the binary but the text itself.

E.g for the text "SCIENCE" the picture should be the result. Has this been done before? I can't find anything on it...

SCIENCE

The solution I found:

from PIL import Image, ImageDraw, ImageFont

img = Image.new('L', (100, 10))
d = ImageDraw.Draw(img)
d.text((1,1), "SCIENCE",255)
img.save('pil_text.png')
Chris A
  • 91
  • 1
  • 10

1 Answers1

1

Use a drawing library to do that, such as PIL - here is a reference which also includes drawing text on an image. Make sure to use PIL.ImageDraw.Draw.textsize to measure the size of the text, then create an image of that size, and then draw the text.

Barak Itkin
  • 4,872
  • 1
  • 22
  • 29