I think you are on the right track. I used this code to see it work, it does. But not sure how to incorporate this into AS.
<!DOCTYPE html>
<html>
<head>
<style>
img {
width: 300px;
height: 300px;
object-fit: contain;
}
</style>
</head>
<body>
<h2>Using object-fit: contain</h2>
<img src="https://mydomain/veggiesP.jpg" alt="Veggies" width="400" height="300">
</body>
</html>
If you use the Camera control, it does not resize but you can get a small b64 file from it. However if you use the BS Input control (inpImage) with inputType=file, as follows, the image object (imgImage) is made proportional, but the b64 file is very large.
Function inpImage_onchange()
imgImage.show()
Try
reader.readAsDataURL(inpImage.files[0])
Catch err
alert("Canceled",0,"Canceled")
End Try
End Function
Function reader_onload(e)
Dim lines()
lines = Split(e.target.result, vbLF)
b64Temp = lines(0)
imgImage.src = b64Temp
End Function
It is possible to get both a small and proportional image but it is a bit complex and requires the user to make a selection on the same image twice. Not very practical. But if there were a way to have the Camera control return the width and height of the picture it could be done with one click.
Note: it looks like the object-fit: contain method will allow loading of images proportionally correct from your domain and not just locally as the camera and input methods do.
John