imagecopymerge合成图片 黑色背景问题

php imagecopymerge合并图片黑色背景问题,多图片合并 黑色背景问题解决

将默认使用的imagecopymerge替换成如下函数

  1. function imagecopymerge_alpha($dst_im$src_im$dst_x$dst_y$src_x$src_y$src_w$src_h$pct){  
  2.         $opacity=$pct;  
  3.         // getting the watermark width  
  4.         $w = imagesx($src_im);  
  5.         // getting the watermark height  
  6.         $h = imagesy($src_im);  
  7.                
  8.         // creating a cut resource  
  9.         $cut = imagecreatetruecolor($src_w$src_h);  
  10.         // copying that section of the background to the cut  
  11.         imagecopy($cut$dst_im, 0, 0, $dst_x$dst_y$src_w$src_h);  
  12.         // inverting the opacity  
  13.         //$opacity = 100 - $opacity;  
  14.                
  15.         // placing the watermark now  
  16.         imagecopy($cut$src_im, 0, 0, $src_x$src_y$src_w$src_h);  
  17.         imagecopymerge($dst_im$cut$dst_x$dst_y$src_x$src_y$src_w$src_h$opacity);  
  18.     }  


图示:
点击在新窗口中浏览此图片

图文合成Demo参考:

点击打开,建议使用手机浏览器打开测试
点击在新窗口中浏览此图片

本文最后更新于 2016-03-14 21:52:57 并被添加「php函数 图片处理」标签,已有 3986 位童鞋阅读过。
本文作者:未来往事
本站使用「署名 4.0 国际」创作共享协议,可自由转载、引用,但需署名作者且注明文章出处

相关文章

此处评论已关闭