PHP the proportions of image
<p>I upload the image to my site. Image has width is 498 and height is 402.
I need to make a preview image with the established maximum width of 250px and a maximum height of 250px, but the image should be 250 to 250, and must be proportional to the width of 250 pixels.</p>

<p>How to do it?</p>

<p><strong>EDIT</strong></p>

<p>I upload images to your server. The limit on the size I want to make 250 in width and 250 in height.
This does not mean that if I upload an image 1000h500, then it must do 250x250, which means that the width we're doing 250 pixels and the height is proportional to the first dimension is 125. In the end, I should get a picture 250x125.
Second example: I have an image 100h800. I mean it should be changed</p>
