I am working on php code where i merge 2 png images into one image. Actually it is school id project. Where i put profile pic on school card.
$profile = imagecreatefrompng("profile.png"); //imagealphablending($profile,true); //imagesavealpha($profile, true); imagecopy($card,$profile,850,280,0,0,1180,700); imagepng($card,"output.png",9); echo '<img src="output.png" />';
how i can remove black ………… i tried all solution on stackoverflow and google but no success
Advertisement
Answer
You should tell the system the width and height of the student photo correctly, otherwise the system will apply black as the background color when merging the two photos.
For PHP, you may use the getimagesize
function to get the correct width and height.
So the code is :
<?php $image_1 = imagecreatefrompng('HIjbp.png'); $image_2 = imagecreatefrompng('Uk5V8.png'); list($width, $height, $type, $attr) = getimagesize('Uk5V8.png'); imagecopy($image_1,$image_2,850,280,0,0,$width,$height); imagepng($image_1, 'result.png'); echo '<img src="result.png" />'; ?>
Working version here: