Jump to content


This topic is now archived and is closed to further replies.


php upload, resizing issue

Recommended Posts

I'm wanting to make an upload script, which first checks if the image's width is over 500px, and if so, create a new file and resize image to 500px width and resize height proportionately to the new width.

Now a script that I have always used that creates new thumbnails for each photo in my gallery, but thats a hard and fast script, no dynamic ability. It simply takes every image and squeezes them down to a specified width and height, and saves them as a new file.

I've read a little and probably can figure out the first part of my problem by using the getimagesize() function to get and challenge the image width being uploaded, but how exactly would i proportionately resize the height?

In a simple case, I could do start like this I suppose:


$dimensions = getimagesize($_FILES['myfile']);
$width = $dimensions[0];

if($width >= 501) {
    // create new file and set new width, but how to proportionately bring in the height too??


Any ideas?

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.