mode prop controls how SanityImage handles aspect ratio changes when you specify both width and height. Understanding the difference between cover and contain is essential for getting the exact image behavior you need.
<SanityImage
id={image._id}
baseUrl="https://cdn.sanity.io/images/abcd1234/production/"
width={500}
height={300}
mode="contain" // or omit, as this is the default
alt="Product image"
/><SanityImage
id={image._id}
baseUrl="https://cdn.sanity.io/images/abcd1234/production/"
width={500}
height={300}
mode="cover"
alt="Product image"
/>