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

Question:

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
Asked By: Jamiu Shaibu

||

Answers:

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:
    ...
Answered By: M.O.
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.