Scale a view based on its content's aspect ratio

Say I have a View with an ImageView in it, how do I limit the main view's resizing so that it only resizes along the aspect ratio of the ImageView? When I resize, I'd expect the image resizes as well.

Some vanilla snippet:

struct ContentView: View {
    @State private var width = 400.0
    @State private var height = 300.0
   @State private var image: Image?
    
    var body: some View {
        VStack {
             image?
                    .resizable()
                    .scaledToFit()
                    .gesture(spatialTap)
        }
    }
}
Scale a view based on its content's aspect ratio
 
 
Q