I have created this simple script but i am afraid that there may be a better way and that there may be leftover temp files. If someone knows what each function is doing exactlly that would be a big help.
$pic ='Blue hills.jpg'; // start image
$loc='thumbs/'; // location to write new file
$new_name='newthumb.jpg'; // new name for image
$new_w=200; // maximum width of the new image
create_image($pic,$loc,$new_name,$new_w); // call function
function create_image($pic,$loc,$new_name,$new_w)
{
$im = imagecreatefromjpeg($pic);
$orwidth=imagesx($im); // get original width
$orheight=imagesy($im); //get original height
$ratio = $orwidth/$orheight; // calc image ratio
$new_h = round($new_w/$ratio,0); // calc new height keeping ratio of original
$new_image=ImageCreateTrueColor($new_w,$new_h);
imagecopyresized($new_image,$im,0,0,0,0,$new_w,$new_h,$orwidth,$orheight);
imagejpeg($new_image,$loc.$new_name,20);
imagedestroy($new_image);
}