Merge a png ontop of a jpg and retain transparency with php

血红的双手。 提交于 2019-12-03 03:41:15

Solution required both using 'imagecopyresampled'. As well a removing lines 4 and 5 from the posted source code.

imagealphablending($dest, false);
imagesavealpha($dest, true);

Here is the complete working version

$dest = imagecreatefromjpeg("example.jpg");
$src = imagecreatefrompng("example.png");

imagecopyresampled($dest, $src, $src2x, $src2y, 0, 0, $src2w, $src2h, $src2w, $src2h); 

header('Content-Type: image/png');
imagejpeg($dest, "user/".$imei."/".$picCount."_m.jpeg");

imagedestroy($dest);
imagedestroy($src);

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