Automatically show with st.number_input( )

I am trying to resize the image and restrict the scale.

I want to achieve the function:
when I change the width, the height will change automatically
and
when I change the height, the width will change automatically

How should I code? Thanks a lot

image