Scale an image to fit some maximum dimension using vanilla JavaScript code
I would probably use Math.max(), as that seems more readable to me and would make what is happening more clear. However, I don't think it will affect efficiency in any meaningful way since it's still making a comparison to determine the max.

var scale = maxdim / Math.max(width, height);