What is the type hint of a function that returns an image?

I have a function that takes 3 arguments and returns an image, I want to know that is the python type hint that the function returns.

Here is my function:

from PIL import Image

def modify_image(img_path: str, width: int, height: int) -> "what here?":
    """Read and return a resized image"""
    image = Image.open(img_path)
    modified_image = image.resize((width, height))

    return modified_image

>Solution :

According to the Pillow documentation, both Image.open() and Image.resize return Pillow Image objects, so your function should look something like

from PIL import Image

def modify_image(img_path: str, width: int, height: int) -> Image:
    ...

Leave a Reply