Insert Text into Image using Python

Publicado em: 16 Agosto 2023
no canal de: Python Peter
55
1

Insert Text into an image in Google Colab using Python.
************************** +Code+ **************************
from PIL import Image, ImageDraw, ImageFont

img = Image.open('/content/drive/MyDrive/images/taifun.png')
display(img)

d = ImageDraw.Draw(img)
fnt = ImageFont.truetype(r'/usr/share/fonts/truetype/ttf-liberation/LiberationSansNarrow-Regular.ttf',100)
fntsmall = ImageFont.truetype(r'/usr/share/fonts/truetype/humor-sans/Humor-Sans.ttf',50)

d.text((100,50),"Taifun", font=fnt, fill=(255,255,255))
d.text((10,160),"This was a big one", font=fntsmall, fill=(255,255,255))

img.save('/content/drive/MyDrive/images/newpic.png')
newimg = Image.open('/content/drive/MyDrive/images/newpic.png')
display(newimg)


Nesta página do site você pode assistir ao vídeo on-line Insert Text into Image using Python duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Python Peter 16 Agosto 2023, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 55 vezes e gostou 1 espectadores. Boa visualização!