79508151

Date: 2025-03-14 04:31:43
Score: 0.5
Natty:
Report link

from PIL import Image, ImageDraw, ImageFont

# Load the image of Ronaldo

image_path = "ronaldo.jpg"

image = Image.open(image_path)

# Create a drawing context

draw = ImageDraw.Draw(image)

# Define the card dimensions (you can adjust these)

card_width, card_height = 400, 600

# Resize the image to fit the card

image = image.resize((card_width, card_height))

# Define the text to be displayed

name = "Cristiano Ronaldo"

jersey_number = "7"

goals = "850" # Example goal count

# Define fonts (you can change the font path to a TTF file on your system)

font_path = "arial.ttf" # Replace with the path to a TTF font file on your system

name_font = ImageFont.truetype(font_path, 30)

number_font = ImageFont.truetype(font_path, 50)

goals_font = ImageFont.truetype(font_path, 25)

# Define text positions

name_position = (50, 20)

number_position = (card_width - 100, 20)

goals_position = (50, card_height - 50)

# Define text colors

text_color = (255, 255, 255) # White

# Add text to the image

draw.text(name_position, name, font=name_font, fill=text_color)

draw.text(number_position, jersey_number, font=number_font, fill=text_color)

draw.text(goals_position, f"Goals: {goals}", font=goals_font, fill=text_color)

# Save the final image

output_path = "ronaldo_card.png"

image.save(output_path)

print(f"Card saved as {output_path}")

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Low reputation (1):
Posted by: HATACHI