python pillow画图

from PIL import Image, ImageDraw

def draw_eclipse(draw, x, y, width, height, fill_color):
    draw.ellipse([x, y, x + width, y + height], fill=fill_color)

def draw_rectangle(draw, x, y, width, height, fill_color):
    draw.rectangle([x, y, x + width, y + height], fill=fill_color)

def draw_triangle(draw, x1, y1, x2, y2, x3, y3, fill_color):
    draw.polygon([(x1, y1), (x2, y2), (x3, y3)], fill=fill_color)

filename = input("Enter the file name: ")
extension = filename[-3:]
name = filename[:len(filename)-4]

if extension.lower() != "png":
    extension = "png"

image = Image.new("RGBA", (500, 500), (0, 0, 0, 0))
draw = ImageDraw.Draw(image)

draw_eclipse(draw, 50, 50, 200, 200, (255, 0, 0))
draw_rectangle(draw, 250, 50, 100, 100, (0, 255, 0))
draw_triangle(draw, 50, 50, 300, 100, 150, 200, (0, 0, 255))

image.save(f"{name}.{extension}")