From pil import image, imagedraw, imagefont # define image dimensions and background color width, height = 800, 600 background_color = (255, 255, 255) # create a new image image = image.new("rgb", (width, height), background_color) draw = imagedraw.draw(image) # define text content and font text = "once upon a time..." font_size = 36 font_color = (0, 0, 0) font_path = "path_to_your_font.ttf" # replace with the path to your font file # load the font font = imagefont.truetype(font_path, font_size) # calculate text size and position text_width, text_height = draw.textsize(text, font) x = (width - text_width) / 2 y = (height - text_height) / 2 # add text to the image draw.text((x, y), text, font=font, fill=font_color) # save the image image.save("children_book_illustration.png") # display the image image.show