$height){ if($width > $setphotoW){ $pratio = ($height / $width); $newpwidth = $setphotoW; $newpheight = ($setphotoW * $pratio); } else {$newpwidth = $width; $newpheight = $height;} }else{ if($height > $setphotoH){ $pratio = ($width / $height); $newpheight = $setphotoH; $newpwidth = ($setphotoH * $pratio); } else {$newpwidth = $width; $newpheight = $height;} } // LOAD IMAGE $newimage = imagecreatetruecolor($newpwidth, $newpheight); if($ext=='image/jpg' || $ext=='image/jpeg' || $ext=='image/pjpeg') {$source = imagecreatefromjpeg($file);} if($ext=='image/png') {$source = imagecreatefrompng($file); } if($ext=='image/gif'){$source = imagecreatefromgif($file);} // RESIZE IMAGE fastimagecopyresampled($newimage, $source, 0, 0, 0, 0, $newpwidth, $newpheight, $width, $height, $quality = 3); // OUTPUT RESIZED IMAGE TO FILE if($ext=='image/jpg' || $ext=='image/jpeg' || $ext=='image/pjpeg') {imagejpeg($newimage,$file); } if($ext=='image/png') {imagepng($newimage,$file); } if($ext=='image/gif') {imagegif($newimage,$file); } /* THIS CREATES THE THUMBNAIL FILE */ $setthumbW = 133; $setthumbH = 100; // GET IMAGE SIZE list($width, $height) = getimagesize($file); // CHECK FOR ORIENTATION AND CHECK IF REDUCTION IS NEEDED // SET REDUCTION AND RATIO IF NEEDED if($width>$height){ $tratio = ($height / $width); $newtwidth = $setthumbW; $newtheight = ($setthumbW * $tratio); }else{ $tratio = ($width / $height); $newtheight = $setthumbH; $newtwidth = ($setthumbH * $tratio); } // LOAD IMAGE $newthumb = imagecreatetruecolor($newtwidth, $newtheight); if($ext=='image/jpg' || $ext=='image/jpeg' || $ext=='image/pjpeg') {$source = imagecreatefromjpeg($file); } if($ext=='image/png') {$source = imagecreatefrompng($file); } if($ext=='image/gif') {$source = imagecreatefromgif($file); } // RESIZE IMAGE fastimagecopyresampled($newthumb, $source, 0, 0, 0, 0, $newtwidth, $newtheight, $width, $height, $quality = 1.5); // OUTPUT RESIZED IMAGE TO FILE if($ext=='image/jpg' || $ext=='image/jpeg' || $ext=='image/pjpeg') {imagejpeg($newthumb,$thumb); } if($ext=='image/png') {imagepng($newthumb,$thumb); } if($ext=='image/gif') {imagegif($newthumb,$thumb); } $field++; } else {header("Location: replacephotos.php?adid=".$listingid."&photo=".$photoid."&errno=1"); exit;} } } header("Location: editad.php?listingid=".$listingid); ?>