def scale_image(img):
    """Scale image to 1920 by 1080"""
    height, width = 1080, 1920  # Desired resolution
    # height, width = 720, 1280  # Desired resolution

    scale_y = min(img.height, height) / max(img.height, height)
    scale_x = min(width, img.width) / max(width, img.width)

    if img.height < height and img.width < width:
        img.scale = max(scale_x, scale_y)
        img.width = img.width / img.scale
        img.height = img.height / img.scale
    else:
        img.scale = min(scale_x, scale_y)
        img.width = img.width * img.scale
        img.height = img.height * img.scale

    return img