Gd is the tool for the job.
After moving the original photo, you should do something like this (off the top of my head):
$gd_input_image = imagecreatefromgif($target_path);
//create a gd image resource from freshly moved photo.
$gd_ouput_image = imagecreatetruecolor(39, 51);
//create a blank image that you will copy to. The important thing to note here is the truecolor portion. If you don't include this, your thumbnail will have a very limited palette (sp?) and look like crap.
imageCopyResized($gd_ouput_image, $gd_input_image, 0, 0, 0, 0, 39, 51, ImageSX($gd_input_image), ImageSY($gd_input_image));
//this is the actual resizing part. this function copys and resizes $gd_input_image to $gd_ouput_image. You should take a look at the manual for more detail on this function.
imagepng($gd_ouput_image, $output_path);
// writes the thumbnail to file (not sure what you want it named, so you'll have to finish this). I would use png for the image format, because they are too small to justify lossy compression (jpeg) and might look really poor with a small palette (gif) - just a though.
I think that's right. Also, you should look into gd's functions.
Hope that helps.
Qest