how can i crop the image with php with its exact to the face of user in image....here is my 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;
}
and here is call of this function
$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);
but it is cropping exact center of the image, that is not right i want to crop the image to face of image eg
and this is the result after cropped
please let me know what is actually the problem....
You would need to detect the image via OCR alike software.
You had to read all pixels and construct the possibility in % if this is a part of the user's pic.
Better let them choose a thumbnail ;)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.