79120614

Date: 2024-10-24 06:31:37
Score: 0.5
Natty:
Report link

Answer of @Basj as a function:

def resize_image_to_fit_to_box(img: np.array, max_width: int, max_height: int):
    f1 = max_width / img.shape[1]
    f2 = max_height / img.shape[0]
    f = min(f1, f2)  # resizing factor
    dim = (int(img.shape[1] * f), int(img.shape[0] * f))
    resized = cv2.resize(img, dim)
    return resized
Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @Basj
Posted by: maniac