php add a picture onto another

女生的网名这么多〃 提交于 2019-11-29 18:24:15

You can try using GD's imagecopymerge function, which copies one image to another and supports alpha transparency. Something like this should work:

<?php
$redimg = imagecreatetruecolor(100, 100);
$image = imagecreatefrompng('image.png');

// sets background to red
$red = imagecolorallocate($redimg, 255, 0, 0);
imagefill($redimg, 0, 0, $red);

// Merge the red image onto the PNG image
imagecopymerge($image, $redimg, 0, 0, 0, 0, 100, 100, 75);

header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
imagedestroy($redimg);
?>

There's more information here.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!