PHP图像 - 将图像添加到使用PHP创建的另一个图像上

Basically I have to work with a ID Card PHP thing that requires me to add the name of a participant and upload a picture. I have a basic template for the ID Card and I'm using PHP to add the name. I have to add the picture of the participant on a particular spot. The name is working but I cannot add a picture of the participant over the generated PHP image. Here's my code:

http://chopapp.com/#arcqwgf4

How should I go about adding the picture over the PHP generate image.

Sorry if this is confusing :/

You are already most of the way there using GD, what you need to do is use imagecopymerge to draw one image on top of the other at a specified point on the base image. PHP.net has quite a few examples on the linked page.

Use the Imagick for things like these. There is a method named combineImages() with which you can achieve your goal.

You can do it with imagecopyresampled method in php.

I created an example here: http://artuc.my.phpcloud.com/artuc/ type name, id and select an image to place it.

Here is the code i used:

header('Content-Type: image/jpeg');
    $canvasImage = imagecreatefromjpeg('sample.jpg');
    $bgcolor = imagecolorallocate($canvasImage, 255, 255, 255);
    imagefill($canvasImage, 0, 0, $bgcolor);

    //Place person picture
    $bgImage = $_POST['idPic'];
    $img = imagecreatefromjpeg($bgImage);
    $imageSize = getimagesize($bgImage);
    imagecopyresampled($canvasImage, $img, 15, 17, 0, 0, $imageSize[0], $imageSize[1], $imageSize[0], $imageSize[1]);

    $fontFile = "Arial.ttf";
    //Place person name
    $black = imagecolorallocate($canvasImage, 0, 0, 0);
    imagettftext($canvasImage, 18, 0, 220, 35, $black, $fontFile, $_POST['idName']);

    //Place person id
    $black = imagecolorallocate($canvasImage, 0, 0, 0);
    imagettftext($canvasImage, 18, 0, 220, 75, $black, $fontFile, $_POST['idNum']);

    //Save Image
    imagejpeg($canvasImage);
    imagedestroy($canvasImage);