Untitled

 avatar
unknown
plain_text
2 months ago
780 B
1
Indexable
from PIL import Image, ImageDraw, ImageFont

# Create an image with a transparent background
width, height = 800, 400
img = Image.new("RGBA", (width, height), (255, 255, 255, 0))

# Load a font
font_size = 50
try:
    font = ImageFont.truetype("arial.ttf", font_size)
except IOError:
    font = ImageFont.load_default()

# Create a drawing context
draw = ImageDraw.Draw(img)

# Define the text
text = "Your Future Awaits.\nOne path unravels, the other illuminates."
text_width, text_height = draw.textsize(text, font=font)

# Calculate text position (centered)
x = (width - text_width) // 2
y = (height - text_height) // 2

# Draw the text
draw.text((x, y), text, fill="black", font=font)

# Save the image
file_path = "/mnt/data/future_quote.png"
img.save(file_path)

file_path

Editor is loading...
Leave a Comment