imagecopymerge合成图片 黑色背景问题
php imagecopymerge合并图片黑色背景问题,多图片合并 黑色背景问题解决
将默认使用的imagecopymerge替换成如下函数
- function imagecopymerge_alpha($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct){
- $opacity=$pct;
- // getting the watermark width
- $w = imagesx($src_im);
- // getting the watermark height
- $h = imagesy($src_im);
- // creating a cut resource
- $cut = imagecreatetruecolor($src_w, $src_h);
- // copying that section of the background to the cut
- imagecopy($cut, $dst_im, 0, 0, $dst_x, $dst_y, $src_w, $src_h);
- // inverting the opacity
- //$opacity = 100 - $opacity;
- // placing the watermark now
- imagecopy($cut, $src_im, 0, 0, $src_x, $src_y, $src_w, $src_h);
- imagecopymerge($dst_im, $cut, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $opacity);
- }
图文合成Demo参考:
最后更新于 2016-03-14 21:52:57 并被添加「php函数 图片处理」标签,已有 3474 位童鞋阅读过。
本站使用「署名 4.0 国际」创作共享协议,可自由转载、引用,但需署名作者且注明文章出处
此处评论已关闭