Well, you'd be using the image functions of course... imagecopyresized() or imagecopyresampled().
The important fact to consider is that while it's still sitting in the upload directory, it will be identified there by a temporary name that PHP gave it; so if you want to manipulate it before moving it around, that's the name you'll be needing to refer to it by.
In other words, the name of the file you'll be checking to see if it's too big, and resizing it if it is, will be $_FILES['userfile']['tmp_name'], where userfile is of course the form field the file was uploaded in.
When you've resized it, if you save it back into the temporary directory ($_ENV['TEMP'] if ini_get('upload_tmp_dir') returns nothing) under the same temporary name, you should be able to move it around as if it had been uploaded in the smaller size to begin with.