Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,44 +1,33 @@
|
|
| 1 |
-
import
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
run_button.click(
|
| 35 |
-
fn=generate_image,
|
| 36 |
-
inputs=prompt,
|
| 37 |
-
outputs=result,
|
| 38 |
-
)
|
| 39 |
-
|
| 40 |
-
return demo
|
| 41 |
-
|
| 42 |
-
if __name__ == "__main__":
|
| 43 |
-
demo = gradio_interface()
|
| 44 |
-
demo.launch()
|
|
|
|
| 1 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 2 |
+
|
| 3 |
+
# Dimensões da imagem
|
| 4 |
+
width, height = 576, 1024
|
| 5 |
+
|
| 6 |
+
# Criar uma imagem branca
|
| 7 |
+
image = Image.new('RGB', (width, height), color='white')
|
| 8 |
+
|
| 9 |
+
# Criar um objeto de desenho
|
| 10 |
+
draw = ImageDraw.Draw(image)
|
| 11 |
+
|
| 12 |
+
# Carregar uma fonte (certifique-se de que a fonte está disponível no seu sistema)
|
| 13 |
+
try:
|
| 14 |
+
font = ImageFont.truetype("arial.ttf", 40)
|
| 15 |
+
except IOError:
|
| 16 |
+
font = ImageFont.load_default()
|
| 17 |
+
|
| 18 |
+
# Texto a ser adicionado à imagem
|
| 19 |
+
text = "Este é um exemplo de texto em uma imagem."
|
| 20 |
+
|
| 21 |
+
# Calcular a posição do texto para centralizá-lo
|
| 22 |
+
text_width, text_height = draw.textsize(text, font=font)
|
| 23 |
+
text_x = (width - text_width) / 2
|
| 24 |
+
text_y = (height - text_height) / 2
|
| 25 |
+
|
| 26 |
+
# Adicionar texto à imagem
|
| 27 |
+
draw.text((text_x, text_y), text, font=font, fill='black')
|
| 28 |
+
|
| 29 |
+
# Salvar a imagem
|
| 30 |
+
image.save('text_image.png')
|
| 31 |
+
|
| 32 |
+
# Exibir a imagem
|
| 33 |
+
image.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|