create image with text python code example
Example 1: put text on image python
from PIL import Image, ImageFont, ImageDraw
my_image = Image.open("image.jpg")
title_font = ImageFont.truetype('font.ttf', 200)
image_editable = ImageDraw.Draw(my_image)
image_editable.text((15,15), "Text goes here", (237, 230, 211), font=title_font)
my_image.save("image-text.jpg")
Example 2: image to text python
from PIL import Image
import pytesseract
image = 'PATH/TO/IMAGE'
text = pytesseract.image_to_string(Image.open(image), lang="eng")
print(text)