Using Min/Max here seems dangerous to me.  Can we not use the known orientation to get the right width and height?