if($_FILES['image1']['tmp_name'] != ""){ //image 1 exists... //see if it is wider or taller... //list($width, $height, $type, $attr) = getimagesize($_FILES['image1']['tmp_name']); if($width > $height){ $istaller = 0;} if($width < $height){ $istaller = 1;} if($width == $height){ $istaller = 2;} //now resize and crop appropriately... //function crop_image($old_image,$new_image,$width,$height,$type="") //firstly crop so that its square $thumb = new Thumbnail($_FILES['image1']['tmp_name']); if($istaller == 0){ $thumb->resize(0,210); $thumb->cropFromCenter(210); }elseif($istaller == 1){ $thumb->resize(210,0); $thumb->cropFromCenter(210); }else{ $thumb->resize(210,210); } $thumb->save("/user_images/testtesttest.jpg",100); }