Correct image aspect ratio for Android Notifications

Something I have been struggling with for a while is getting my camera notification images to display correctly on my phone. The image from my camera is in a 4:3 ratio and android crops the image to 2:1 ratio in the notification and I often lose the parts of an image where people enter and exit the view.

The camera_proxy has some image resizing options, however they dont do exactly what I need. so I started there and modified the crop/resize function and have come up with this. it creates a new black image of the desired aspect ratio and pastes in the original image. essentially padding the image, the idea being that the whole image is visible in the notification but with a black bar on the side or bottom

def _pad_2to1ratio(image, opts):
    """Pad image to 2:1 ratio"""
    try:
        img = _precheck_image(image, opts)
    except ValueError:
        return image

    quality = opts.quality or DEFAULT_QUALITY

    (old_width, old_height) = img.size
	old_size = len(image)
    if old_width == (2 * old_height):
        _LOGGER.debug("Image is correct ratio")
        return image
    elif old_width > (2 * old_height):
        result = Image.new(img.mode, (old_width, old_width / 2), (0, 0, 0))
        result.paste(img, (0, (old_width - old_height) / 2))

    else:
        result = Image.new(img.mode, (old_height * 2, old_height), (0, 0, 0))
        result.paste(img, ((old_height * 2 - old_width) / 2, 0))

    imgbuf = io.BytesIO()
	result.save(imgbuf, "JPEG", optimize=True, quality=quality)
    newimage = imgbuf.getvalue()
	
	(new_width, new_height) = newimage.size
	
    _LOGGER.debug(
        "Padded image from (%dx%d - %d bytes) to (%dx%d - %d bytes)",
        old_width,
        old_height,
        old_size,
        new_width,
        new_height,
        len(newimage),
    )
    return newimage

there is also some other changes to the file to call the method etc… however this is way above my pay grade. I just don’t how how to take this further and test it out. I have been trying for months now…

have you seen this comment Home Assistant Companion Apps: New and Upcoming Features - #48 by joax01

I hadn’t seen that thread, I have just tried to create proxy as per the other thread, tried a dozen different resolutions and it still crops the image. the issue being the proxy doesn’t adjust the aspect ratio. hence the need to pad the image

my notification images are 640x480 and 640x360.

I cant be the only one who see’s this?