0

Possible Duplicate:
Facial recognition/detection PHP or software for photo and video galleries

I'm trying coding to merge a portrait into available frame picture. By using WideImage PHP Lib, I can manipulate on image, this is my code:

//Load image from disk
$img = WideImage::load($fileName); //our character
$watermark = WideImage::load($framePath.'photo_frame.png'); //load frame picture

//crop img to fit into frame
$hWatermark = $watermark->getHeight();
$wWatermark = $watermark->getWidth();
$img = $img->resize($wWatermark, $hWatermark, "outside");
$hImg = $img->getHeight();
$wImg = $img->getWidth();
if($hImg > $hWatermark) {
    $img = $img->crop(0, 0, $width = "100%", $height = $hWatermark);
}
if($wImg > $wWatermark) {
    $img = $img->crop(0, 0, $width = $wWatermark, $height = "100%");
}

// place the frame override image
$new = $img->merge($watermark, $left = 0, $top = 0, $pct = 100);

//Result is a new image with our character in a frame
$new->output('jpg', 90);

With above block code, I can make a new picture, but if the face doesn't locate near at top-left corner, a new picture doesn't focus to the face. Example: Merge two image result

I think I can not afford to write code automatically detects faces, but we have a simple way is to allow users to select an area to collage. How do implementation this way onto HTML & js? Thank for your help!

Community
  • 1
  • 1
Davuz
  • 5,040
  • 13
  • 41
  • 61

0 Answers0