码迷,mamicode.com
首页 > Web开发 > 详细

php透明合并png与jpg图片

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

标签:des   style   blog   http   color   width   

 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图片

标签:des   style   blog   http   color   width   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!