Sobes.tech
Junior — Senior

Image resizing with aspect ratio preservation

livecode

Task condition

Implement the resize function that takes the current width and height of an image and returns their new values, scaled proportionally, such that:

  • the width does not exceed 800 pixels;
  • the height does not exceed 600 pixels;
  • the original aspect ratio of the image is preserved.
from typing import Final, Tuple

MAX_W: Final[int] = 800
MAX_H: Final[int] = 600

def resize(width: int, height: int) -> Tuple[int, int]:
    pass