Location: PHPKode > projects > PHPDug > includes/functions/func.users.php
<?php
function resizeimg($file,$width,$height,$newfile)
{
	$h_force=-1;
	$w_force=-1;
	$imageinfo = getimagesize($file);
	$im_filetype = $imageinfo[2];
	
	if($im_filetype==IMAGETYPE_JPEG) 
	{
		$source = imagecreatefromjpeg($file);
	}
	if($im_filetype==IMAGETYPE_PNG) 
	{
		$source = imagecreatefrompng($file);
	}
	if($im_filetype==IMAGETYPE_GIF) 
	{
		$source = imagecreatefromgif($file);
	}

	if (!is_resource($source)) 
	{
		return 0; 
	}

	$original_x=imageSX($source);
	$original_y=imageSY($source);
	
	$thumb_w=$width;
	$thumb_h=$height;
				
	$dst_img=imagecreatetruecolor($thumb_w,$thumb_h);

	imagecopyresampled($dst_img, $source,0,0,0,0,$thumb_w,$thumb_h,$original_x,$original_y);
	imagejpeg($dst_img,$newfile,90);
	imagedestroy($dst_img);
	imagedestroy($source);
	
	return $newfile;
}

function removeuserimg($id)
{
	$lsb = dechex($id & 255);
	$msb = dechex(($id >> 8 ) & 255);
	
	if (strlen($lsb)==1) {$lsb = "0$lsb";}
	if (strlen($msb)==1) {$msb = "0$msb";}
	
	$path = 'images/avatars/'.$msb.'/'.$lsb.'/'.$id.'/';
	
	if(file_exists($path.'s'.$id.'.jpg'))
	{
		unlink($path.'s'.$id.'.jpg');
	}
	if(file_exists($path.'m'.$id.'.jpg'))
	{
		unlink($path.'m'.$id.'.jpg');
	}
	if(file_exists($path.'l'.$id.'.jpg'))
	{
		unlink($path.'l'.$id.'.jpg');
	}
}
?>
Return current item: PHPDug