resize billede
hej jeg har følgende kode til at resize et billede.hvordan får jeg den til at resize den orginale billede til et bestem width???
function createT_img($imgName, $sou, $mappen) {
//resize image to put it into db
$imagename = $imgName;
$source = $sou; //$_FILES['img1']['tmp_name'];
$target = $mappen."/".$imagename;
$map = $mappen;
move_uploaded_file($source, $target);
$imagepath = $imagename;
$save = $mappen ."/sml/". $imagepath; //This is the new file you saving
$file = $mappen ."/". $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modwidth = $width;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
$save = $mappen ."/sml/" . $imagepath; //This is the new file you saving
$file = $mappen ."/". $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modwidth = 180;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
return $imagepath;
}