Very important help!

I have this code and it generates thumbnails from jpg images, down to 20x20

I want it to also generate and store a seperate image at 230x171 [if and only if it is larger than that given size] (as thats the size that best fits my iframe, without scrollers.)

It should be easy, but for some reason, i cant figure it out. Any help? Here is the code.

One other thing, The name of the new image MUST REMAIN THE SAME!!!
There will be three images with the same name, in three different folders.

/
/thumb/
/large/

those are the folders. Please help with this. I am so lost as how.

<?
$add="/LOCATIONOFFOLDERONSERVER/$userfile_name"; // the path with the file name where the file will be stored, upload is the directory name. 
if(move_uploaded_file ($userfile, $add)){
echo "Successfully uploaded the image";
chmod("$add",0777);

}else{echo (mysql_error() . "<br>Failed to upload file");
exit;}

///////// Start the thumbnail generation//////////////
$n_width=20;          // Fix the width of the thumb nail images
$n_height=20;         // Fix the height of the thumb nail imaage

$tsrc="thumb/$userfile_name";   // Path where thumb nail image will be stored
("<br>" . $tsrc);
if (!($userfile_type =="image/pjpeg" OR $userfile_type=="image/gif")){echo "Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
exit;}
/////////////////////////////////////////////// Starting of GIF thumb nail creation///////////
if (@$userfile_type=="image/gif")
{
$im=ImageCreateFromGIF($add);
$width=ImageSx($im);              // Original picture width is stored
$height=ImageSy($im);                  // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
if (function_exists("imagegif")) {
Header("Content-type: image/gif");
ImageGIF($newimage,$tsrc);
}
elseif (function_exists("imagejpeg")) {
Header("Content-type: image/jpeg");
ImageJPEG($newimage,$tsrc);
}
chmod("$tsrc",0777);
}////////// end of gif file thumb nail creation//////////

////////////// starting of JPG thumb nail creation//////////
if($userfile_type=="image/pjpeg"){
$im=ImageCreateFromJPEG($add); 
$width=ImageSx($im);              // Original picture width is stored
$height=ImageSy($im);             // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);                 
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
ImageJpeg($newimage,$tsrc);
chmod("$tsrc",0777);
}
////////////////  End of JPG thumb nail creation //////////

//end of code