def METHOD_NAME(
    w: int, h: int, target: int, side: SideSelection, condition: ResizeCondition
) -> Tuple[int, int]:
    def compare_conditions(b: int) -> bool:
        if condition == ResizeCondition.BOTH:
            return False
        if condition == ResizeCondition.DOWNSCALE:
            return target > b
        elif condition == ResizeCondition.UPSCALE:
            return target < b
        else:
            raise RuntimeError(f"Unknown condition {condition}")
    if side == SideSelection.WIDTH:
        if compare_conditions(w):
            w_new = w
            h_new = h
        else:
            w_new = target
            h_new = max(round_half_up((target / w) * h), 1)
    elif side == SideSelection.HEIGHT:
        if compare_conditions(h):
            w_new = w
            h_new = h
        else:
            w_new = max(round_half_up((target / h) * w), 1)
            h_new = target
    elif side == SideSelection.SHORTER_SIDE:
        if compare_conditions(min(h, w)):
            w_new = w
            h_new = h
        else:
            w_new = max(round_half_up((target / min(h, w)) * w), 1)
            h_new = max(round_half_up((target / min(h, w)) * h), 1)
    elif side == SideSelection.LONGER_SIDE:
        if compare_conditions(max(h, w)):
            w_new = w
            h_new = h
        else:
            w_new = max(round_half_up((target / max(h, w)) * w), 1)
            h_new = max(round_half_up((target / max(h, w)) * h), 1)
    else:
        raise RuntimeError(f"Unknown side selection {side}")
    return w_new, h_new