$dst_path = 'background.jpg'; // 背景图
$src_path = 'qr.jpg';  // 二维码图
//创建图片的实例
$dst = imagecreatefromstring(file_get_contents($dst_path));
$src = imagecreatefromstring(file_get_contents($src_path));
// 把二维码图片的白色背景设为透明
imagecolortransparent($src, imagecolorallocate($src, 255, 255, 255));
//获取水印图片的宽高
list($src_w, $src_h) = getimagesize($src_path);
var_dump(getimagesize($src_path));
//将水印图片复制到目标图片上
imagecopymerge($dst, $src, 114, 243, 0, 0, $src_w, $src_h, 100);
//生成图片
imagepng($dst,'test2.png');
//销毁 imagedestroy($dst); imagedestroy($src);

  合成效果

php之把两个图片合成

 

相关文章:

  • 2021-12-19
  • 2022-12-23
  • 2022-02-14
  • 2021-07-31
  • 2022-02-22
  • 2021-11-01
  • 2021-11-30
猜你喜欢
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2022-01-26
  • 2021-09-11
  • 2022-12-23
  • 2021-11-19
相关资源
相似解决方案