Recently I needed to enlarge and shrink images proportionally1 in Wordpress2, so I wrote a couple PHP functions to help with the math3. In both, you supply the original height and width, and then maximum or minimum dimensions. If the original height and width fit within your maximum or minimum, the functions return null, if not they return an array with new proportional dimensions.
Resizing the images proportionally means that they will maintain their original [aspect ratio](https://en.wikipedia.org/wiki/Aspect_ratio_(image%29) and not look distorted. ↩
In Wordpress you can use registered image sizes to shrink images proportionally, but there is nothing for enlarging them. ↩