I've seen lots of similar scripts but I've not found one that quite does what I need.
My site allows user to upload pictures. When displayed I want the images to stretch to 250px in one direction, width or height depending on which is greater, and keep the aspect ratio in the other direction (without going beyond 250px).
At the minute I have just set the HTML img element to this, but it distorts the ratio.
You would have to resize it in PHP... but you can't have it 250px width or height, then have the other not exceed 250px while keeping the same aspect ratio... to keep the aspect ratio you can only specify width or height to be 250px max, the other will adjust accordingly.
You can make an ajax type script that loads the resized image from the server. It' s quite easy.
Other method is to hide parts of the picture using CSS.
You can resize it on PHP, when you do the upload.
Ohterwise, using PHP when display, you can look if its width is bigger than its height or not and only use one attribute