PHP Merge 2 Images Insert Face To An Image

0 votes

I have 2 images. one face image and one frame image and I want to insert the face image into the frame image.

So I tried this code:

<?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 that the resolution of the output image is not that of the frame image. And I wanted to change the position of the face image. How can I do these things?

May 27 in PHP by Kichu
• 19,040 points
18 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
0 answers

How can i send an image map area id to a php file?

This is my image map: <map name="frozen"> ...READ MORE

Jun 16 in PHP by narikkadan
• 10,840 points
11 views
0 votes
1 answer

How to convert an image to base64 encoding?

Hello @kartik, You can also do this via ...READ MORE

answered Apr 1, 2020 in PHP by Niroj
• 82,700 points
2,098 views
0 votes
1 answer

How to merge two arrays while keeping keys instead of reindexing in php?

Hello, Considering that you have $replaced = array('1' => ...READ MORE

answered Apr 1, 2020 in PHP by Niroj
• 82,700 points
781 views
0 votes
1 answer

How to resolve “must be an instance of string, string given” prior to PHP 7?

Hello, Prior to PHP 7 type hinting can only be ...READ MORE

answered Apr 20, 2020 in PHP by I Navin
• 220 points
2,766 views
0 votes
1 answer

How do I convert a PDF document to a preview image in PHP?

Hello @kartik, You need ImageMagick and GhostScript <?php $im = new imagick('file.pdf[0]'); $im->setImageFormat('jpg'); header('Content-Type: image/jpeg'); echo ...READ MORE

answered Aug 14, 2020 in PHP by Niroj
• 82,700 points
2,790 views
0 votes
1 answer

How to remove duplicate values from an array in PHP?

Hello @kartik, Use array_unique(): Example: $array = array(1, 2, 2, 3); $array ...READ MORE

answered Sep 15, 2020 in PHP by Niroj
• 82,700 points
1,369 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
1,663 views
+2 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP