how can i crop the image with php with its exact to the face of user in image....here is my code....\[code\]function resizeImage($image,$width,$height,$scale) { list($imagewidth, $imageheight, $imageType) = getimagesize($image); $imageType = image_type_to_mime_type($imageType); $newImageWidth = ceil($width * $scale); $newImageHeight = ceil($height * $scale); $newImage = imagecreatetruecolor($newImageWidth,$newImageHeight); switch($imageType) { case "image/gif": $source=imagecreatefromgif($image); break; case "image/pjpeg": case "image/jpeg": case "image/jpg": $source=imagecreatefromjpeg($image); break; case "image/png": case "image/x-png": $source=imagecreatefrompng($image); break; } imagecopyresampled($newImage,$source,0,0,0,0,$newImageWidth,$newImageHeight,$width,$height); switch($imageType) { case "image/gif": imagegif($newImage,$image); break; case "image/pjpeg": case "image/jpeg": case "image/jpg": imagejpeg($newImage,$image,90); break; case "image/png": case "image/x-png": imagepng($newImage,$image); break; } chmod($image, 0777); return $image;}\[/code\]and here is call of this function\[code\]$wwidth = getWidth($new_small_image); $hheight = getHeight($new_small_image); $x1 = $wwidth/2; $y1 = $hheight/2; $x2 = 0; $y2 = 0; $w = 50; $h = 50; $scale = $thumb_width/$w; resizeThumbnailImage($new_small_image, $new_small_image,$w,$h,$x1,$y1,$scale);\[/code\]but it is cropping exact center of the image, that is not right i want to crop the image to face of image e.g
and this is the result after cropped
please let me know what is actually the problem....