Problems with this php to upload jpg image with set dimensions and file size

I am having problems with the script below!

I want my upload script to be a jpg that is no more than 200kb and has the dimensions of 90px by 100px!

the script below does the file type and size but not the dimensions!

can anyone help with how to sort this out?

<?php
include "layout.php";


//If the post is full then carry out the following
if(isset($_POST['add']))
{


//What all the form stuff is set to
	  $maxfilesize=200000; 	//the max image size in bytes
	  $max_width=90;		//the max width
	  $max_height=100;		//the max height

if(!is_uploaded_file($HTTP_POST_FILES['img1']['tmp_name']) &&
!isset($error)){
	$error = "<b>You must upload a file!</b><br><br>";
	unlink($HTTP_POST_FILES['img1']['tmp_name']);
	
}
if ($HTTP_POST_FILES['img1']['size'] > $maxfilesize && !isset($error)) {
	$error = "<b>Error file must be less than $maxfilesize bytes.</b><br><br>";
	unlink($HTTP_POST_FILES['img1']['tmp_name']);
	
}
if ($HTTP_POST_FILES['img1']['dimensions'] > $max_width && $max_height && !isset($error)) {
	$error = "<b>Image size not correct</b><br><br>";
	unlink($HTTP_POST_FILES['img1']['tmp_name']);

}	
if(($HTTP_POST_FILES['img1']['type'] != "image/jpg") && ($HTTP_POST_FILES['img1']['type'] != "image/jpeg")&& ($HTTP_POST_FILES['img1']['type'] != "image/pjpeg")&& ($HTTP_POST_FILES['img1']['type'] != "image/pjpg") &&
!isset($error)) {
	$error = "<b>You may only upload .jpg or .jpeg file formats</b><br><br>";
	unlink($HTTP_POST_FILES['img1']['tmp_name']);
	
}
if (!isset($error)) {
copy($HTTP_POST_FILES['img1']['tmp_name'],"theuploadedimages/".$HTTP_POST_FILES
['img1']['name']);
	unlink($HTTP_POST_FILES['img1']['tmp_name']);
	print "Thank you for your upload.<br><br>";
	  
	  
    $title = $_POST['title'];
    $description = $_POST['description'];
    $image=($_FILES['img1']['name']);


if(!get_magic_quotes_gpc())
{
//ensures everything is correctly entered into database, to allow quotes and stuff
	  $title = addslashes ($title);
      $description = addslashes ($description);
      $image = addslashes ($image);   


}
include 'include/db_login.php';
include 'include/mysql_connect.php';



$query = " INSERT INTO site_images (title, description, image) ".
		 " VALUES ('$title', '$description', '$image')";
mysql_query($query) or die('Error, query failed');

include 'include/closedb.php';

echo "New Image '$title' added <br><br><a href=\"port_add.php\">Add another mugshot, maybe a friend?</a><br><a href=\"index.html\">Go back to Mughshot!</a>";

			$title = stripslashes ($title);
			$description = stripslashes ($description);
			$image = stripslashes ($image);   


exit;
}
else
{
	echo ("$error");
}
}
?>

:stuck_out_tongue: