Datei
"c:\users\email\onedrive\Personal\Documents\Code\Python\TestPatternReTeNection /> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Code: Select all
from PIL import Image, ImageDraw, ImageFont
# Create an image object
img = Image.new("RGB", (400, 400), (255, 255, 255))
# Create a draw object
draw = ImageDraw.Draw(img)
# Define the font to be used for the text
font = ImageFont.truetype("arial.ttf", 36)
# Get the text bounding box
text = "Hello World!"
textwidth, textheight = draw.textbbox(text, font=font)
# Calculate the position for the text
x = (img.width - textwidth) / 2
y = (img.height - textheight) / 2
# Draw the text on the image
draw.text((x, y), text, (0, 0, 0), font=font)
# Save the image
img.save("hello_world.png")