in src/mapillary/controller/image.py [0:0]
def get_image_thumbnail_controller(image_id: str, resolution: int) -> str:
"""
This controller holds the business logic for retrieving
an image thumbnail with a specific resolution (256, 1024, or 2048)
using an image ID/key
:param image_id: Image key as the argument
:type image_id: str
:param resolution: Option for the thumbnail size, with available resolutions:
256, 1024, and 2048
:type resolution: int
:return: A URL for the thumbnail
:rtype: str
"""
# check if the entered resolution is one of the supported image sizes
resolution_check(resolution)
try:
res = Client().get(Entities.get_image(image_id, [f"thumb_{resolution}_url"]))
except HTTPError:
# If given ID is an invalid image ID, let the user know
raise InvalidImageKeyError(image_id)
return json.loads(res.content.decode("utf-8"))[f"thumb_{resolution}_url"]