I've got this url builder function:
urlForImage(product.image.asset._ref).auto('format').orientation(isImageStanding ? 90 : 0).width(isImageStanding ? 338 : 450).height(isImageStanding ? 450 : 338).url()
When the orientation is 0 it's a rectangle like I want. When I rotate it, it returns a square with dimensions 338x338.
I tried swapping the width and height, but this didn't work.
Try adding .fit('max')
urlForImage(product.image.asset._ref).auto('format').orientation(isImageStanding ? 90 : 0).width(isImageStanding ? 338 : 450).height(isImageStanding ? 450 : 338).fit('max').url()