in src/co_op_translator/utils/vision/image_utils.py [0:0]
def draw_text_on_image(text, font, text_color):
"""
Draw text onto an image with a transparent background.
Args:
text (str): The text to draw.
font (PIL.ImageFont.ImageFont): The font object.
text_color (tuple): The text color (R, G, B).
Returns:
PIL.Image.Image: The image with text.
"""
size = tuple(font.getbbox(text)[2:]) # width and height of the text
text_image = Image.new("RGBA", size, (255, 255, 255, 0))
draw = ImageDraw.Draw(text_image)
draw.text((0, 0), text, font=font, fill=text_color)
return text_image