I'm working on a PHP script that adds images to articles automatically. A common problem I've encountered is that the image dimensions can be too wide or too tall.
In terms of aspect ratio of wide images, I don't want it to be beyond 300x200 pixels:
So for example, the following dimensions are okay:
1000x700
100x80
200x300
The following are bad:
100x50
500x200
1200x700
Those are too wide pictures.
In terms of tall pictures, I don't want the image to be taller than a 100x200 aspect ratio:
So, 500x900 is fine, but 500x1005 is not.
What type of calculation can I do to determine if the picture is way too wide, way to tall, or acceptable?
I have $width and $height variables that I can use in this calculation.


I don't know PHP, but something like the following (change the thresholds to your liking)