首页 > Web开发 > 详细

php透明合并png与jpg图片

时间:2014-07-22 22:40:44      阅读:443      评论:0      收藏:0      [点我收藏+]

 1 <?php
 2 $png = imagecreatefrompng(‘./mark.png‘);
 3 $jpeg = imagecreatefromjpeg(‘./image.jpg‘);
 4 
 5 list($width, $height) = getimagesize(‘./image.jpg‘);
 6 list($newwidth, $newheight) = getimagesize(‘./mark.png‘);
 7 $out = imagecreatetruecolor($newwidth, $newheight);
 8 imagecopyresampled($out, $jpeg, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
 9 imagecopyresampled($out, $png, 0, 0, 0, 0, $newwidth, $newheight, $newwidth, $newheight);
10 imagejpeg($out, ‘out.jpg‘, 100);
11 ?>
 1 另外一种方法:
 2 
 3 $dest = imagecreatefrompng(‘mapCanvas.png‘);
 4 $src = imagecreatefromjpeg(‘si.jpg‘);
 5 imagealphablending($dest, false);
 6 imagesavealpha($dest, true);
 7 // Copy and merge
 8 imagecopymerge($dest, $src, 17, 13, 0, 0, 60, 100, 100);
 9 
10 // Output and free from memory
11 header(‘Content-Type: image/png‘);
12 imagepng($dest);
13 
14 imagedestroy($dest);
15 imagedestroy($src);

php透明合并png与jpg图片,布布扣,bubuko.com

php透明合并png与jpg图片

原文:http://www.cnblogs.com/Fadinglemon/p/3860231.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!