Image resize

Hi i have a php file that outputs images how can i change the size of the images to a smaller version of that image.
here is the code that im using.

 $directory = 'thumbs/'.$row['lastname'].'';


$dir_handle = @opendir($directory) or die("There is an error with your image directory!");

while ($file = readdir($dir_handle))
	if($file=='.' || $file == '..') continue;
	$file_parts = explode('.',$file);
	$ext = strtolower(array_pop($file_parts));

	$title = implode('.',$file_parts);
	$title = htmlspecialchars($title);
		if(($i+1)%4==0) $nomargin='nomargin';
		echo '
		<div class="pic '.$nomargin.'" style="background:url('.$directory.'/'.$file.') no-repeat 50% 50%;">
		<a href="'.$directory.'/'.$file.'" title="'.$title.'" target="_blank">'.$title.'</a>



What image processing extensions are installed in your PHP configuration? Do you have GD2?

Hi I have
GD Version bundled (2.0.34 compatible)