|
<?
$picfile=$_FILES['file']['name']; $ext = substr($picfile,-3); $ext = strtolower($ext); if(($ext=="gif") OR ($ext=="jpg") OR ($ext=="png")) { // CREATING & RESIZING THUMBNAIL TO 150 px WIDE $uploadedfile = $_FILES['file']['tmp_name']; if($ext=="gif"){$src = imagecreatefromgif($uploadedfile);} if($ext=="jpg"){$src = imagecreatefromjpeg($uploadedfile);} if($ext=="png"){$src = imagecreatefrompng($uploadedfile);} list($width,$height)=getimagesize($uploadedfile); // Setting the thumbnail to be 150 pixels wide, $newwidth=150; $newheight=($height/$width)*150; $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); // Writing the resized image in the ./thumbs subdirectory. $filename = "./thumbs/$picfile"; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); // RESIZING PIC TO 700 px WIDE $uploadedfile = $_FILES['file']['tmp_name']; if($ext=="gif"){$src = imagecreatefromgif($uploadedfile);} if($ext=="jpg"){$src = imagecreatefromjpeg($uploadedfile);} if($ext=="png"){$src = imagecreatefrompng($uploadedfile);} list($width,$height)=getimagesize($uploadedfile); // Setting the picture to be 700 pixels wide, $newwidth=700; $newheight=($height/$width)*700; $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); // Writing the resized image in the ./pics subdirectory. $filename = "./pics/$picfile"; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); } ?> |