Download the Guru IA app

Android and iOS

Foto de perfil

Carlos

estudos gerais02/03/2025

from PIL import Image, ImageDraw, ImageFont # Carregar a ...

from PIL import Image, ImageDraw, ImageFont

Carregar a imagem gerada

image_path = "/mnt/data/An_inspiring_and_dynamic_illustration_representing.png" image = Image.open(image_path)

Criar um desenho na imagem

draw = ImageDraw.Draw(image)

Definir a fonte (usando uma fonte padrão)

font_path = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf" font_size = 60 font = ImageFont.truetype(font_path, font_size)

Definir o texto

text = "Desenvolvimento Pessoal\nA Chave para o Seu Sucesso"

Definir a posição do texto

text_width, text_height = draw.textsize(text, font=font) image_width, image_height = image.size x = (image_width - text_width) // 2 y = image_height - text_height - 50 # Posicionar na parte inferior

Adicionar o texto à imagem

text_color = "white" draw.text((x, y), text, fill=text_color, font=font, align="center")

Salvar a imagem editada

edited_image_path = "/mnt/data/desenvolvimento_pessoal_capa.png" image.save(edited_image_path) edited_image_path

Send your questions through the App
Equipe Meu Guru

Do you prefer an expert tutor to solve your activity?

  • Receive your completed work by the deadline
  • Chat with the tutor.
  • 7-day error guarantee