Merge PHP 2 images (insert face to image)

I need your help

I have two images,
1. http://i.imgur.com/pyWGk.jpg (face image, type: jpeg)
2. http://i.imgur.com/LYk07.png (frame image, with a hole in person, type: png)

I want to insert a face image in a frame image

I tried this script

<?php
$image = imagecreatefromjpeg('face.jpg');
$frame = imagecreatefrompng('ironman.png');

$iw = imagesx($image);
$ih = imagesy($image);

$fw = imagesx($frame);
$fh = imagesy($frame);

imagealphablending($frame, true);
imagesavealpha($frame, true);
imagecopy($image, $frame, 0, 0, 0, 0, $fw, $fh);

header('Content-Type: image/jpeg');
imagejpeg($image);

imagedestroy($image);
imagedestroy($frame);
?>

The problem is as follows: The
resolution of the image of the result does not match the resolution of the image of the frame and
How to change the position of the image of the face, so the image of the face can be directly on the hole in the image of the frame

+5
source share
1 answer

. :

function scale($scale){
    //you can get image width and height from image info
    $width = $image_width * $scale / 100;
    $height = $image_height * $scale / 100;

    $scaled_image = imagecreatetruecolor($width, $height);
    imagecopyresampled($scaled_image, $old_image, 0, 0, 0, 0, $width, $height, $image_width, $image_height);
}

, , imagecopy. dst_x dst_y.

0

All Articles