zoukankan      html  css  js  c++  java
  • 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);
  • 相关阅读:
    阅读《构建之法(第三版)》提出的问题
    职位部门管理系统
    JSON
    hashcode()和equals()方法
    JSF和Facelets的生命周期
    认识applet
    认识ajax
    hello1.java分析
    vue中的防抖和节流
    vue项目搭建
  • 原文地址:https://www.cnblogs.com/Fadinglemon/p/3860231.html
Copyright © 2011-2022 走看看