zoukankan      html  css  js  c++  java
  • php图片叠加

    单图片

    //图片叠加

    function imagealphaMerge($dst,$src,$d_x,$d_y,$s_x,$s_y,$s_w,$s_h,$alpha){
        $dst_im = imagecreatefromjpeg($dst);
        $src_im = imagecreatefromjpeg($src);
        imagecopymerge($dst_im,$src_im,$d_x,$d_y,$s_x,$s_y,$s_w,$s_h,$alpha);
        imagejpeg($dst_im);
        imagedestroy($dst_im);
        imagedestroy($src_im);
    }
    imagealphaMerge('Chrysanthemum.jpg',$src,0,0,0,0,300,300,50);
    

    多图片

    $src = array('Koala.jpg','Tulips.jpg');
    function imagealphaMerge($dst,$src,$d_x,$d_y,$s_x,$s_y,$s_w,$s_h,$alpha){
    	 $dst_im = imagecreatefromjpeg($dst);
    	 $num = count($src);
    	 for ($i=0; $i<$num; $i++)
    	 {
    		$src_im = imagecreatefromjpeg($src[$i]);
    		imagecopymerge($dst_im,$src_im,$d_x,$d_y,$s_x,$s_y,$s_w,$s_h,$alpha);
    	 }
    	 imagejpeg($dst_im);
    	 imagedestroy($dst_im);
         imagedestroy($src_im);
     }
     imagealphaMerge('Chrysanthemum.jpg',$src,0,0,0,0,300,300,50);
    

    这里是用jpg图片做的测试,如果其他图片请更换imagecreatefromjpeg,imagejpeg。同时修改图片路径

  • 相关阅读:
    4.22课堂
    4.21课堂
    4.20作业
    4.20课堂
    4.17课堂
    4.16课堂
    4.15作业
    4.15反射与内置方法
    4.10绑定与非绑定
    70、django中间件
  • 原文地址:https://www.cnblogs.com/zhaozhilu/p/2751337.html
Copyright © 2011-2022 走看看