php透明合并png与jpg图片
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);
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。