Java to maintain aspect ratio based on constant width size?

Here’s a JS question;

I have a tool for users to create an image of a double glazed window, they input theiir height and width values. The image created needs to show the user a representation of what they will get, the absolute size is not important, but the user needs to see the correct aspect ratio of their inputted height/width - but I also need to fix the width on my Bubble page to 500px wide.

So, assume the user creates a window 900 wide x 650 high. I need to shrink the image to be 500px wide, and then make the height the correct height based on the original aspect ratio 900 x 650.

Any know how this can be done?

Here’s an example, both images below restrict the visual group to 500px wide, regardless of the users inputted size. However, I don;t know how to maintain the original inputted aspect ratio.

Example of 1000x300 (reduced to 500px wide)

Screenshot 2022-09-21 090806

Example of 700x500 (reduced to 500px wide)

Screenshot 2022-09-21 091118

Hi @darren.james7518 :wave:

While displaying the images in the container
You can play with this & check (It might help, Regarding aspect ratio i am not sure)…

Thanks but that won’t work because the aspect ratio is never fixed, it would be depended on the users imputed width/height. This would have worked if I maintained the same aspect ration for all images.

1 Like

@darren.james7518 Ah ok, sorry i misunderstood the question :man_facepalming: