php合并圖片

來源:互聯網
上載者:User

標籤:ges   sam   ddl   產生   空白   led   ima   get   技術   

 1 function combineImage($head_img,$middle_img,$footer_img,$save_path){ 2     $source_w = 400; 3     $source_h = 1142; 4     //取頭部圖片大小 5     $head_size = getimagesize($head_img); 6     $head_height = $head_size[‘1‘]; 7     $head_width = $head_size[‘0‘]; 8     $head_start_x = floor(($source_w-$head_width)/2);//頭部開始位置 9     //取中間圖片大小10     $midd_size = getimagesize($middle_img);11     $midd_height = $midd_size[‘1‘];12     $midd_width = $midd_size[‘0‘];13     $midd_start_y = $head_height-15;//中間開始Y座標,因為頭部的圖片底部有空白,所以減去1514     $midd_start_x = floor(($source_w-$midd_width)/2);15     16     //取底部圖片大小17     $foot_size = getimagesize($footer_img);18     $foot_height = $foot_size[1];19     $foot_width = $foot_size[0];20     $foot_start_x = floor(($source_w-$foot_width)/2);//底部圖片x座標21     $foot_start_y = $source_h-$foot_height;//底部圖片y座標22     23     $head = imagecreatefrompng($head_img);24     $middle = imagecreatefrompng($middle_img);25     $footer = imagecreatefrompng($footer_img);26     27     $bg_img = imageCreatetruecolor($source_w,$source_h);//產生背景圖片28     $color = imagecolorallocate($bg_img, 255, 255, 255); //設定白色背景29     imagefill($bg_img, 0, 0, $color);//背景色填充30     imageColorTransparent($bg_img, $color);//透明31     imagecopyresampled($bg_img,$head,$head_start_x,0,0,0,$head_width,$head_height,$head_width,$head_height);32     imagecopyresampled($bg_img,$middle,$midd_start_x , $midd_start_y,0,0,$midd_width,$midd_height,$midd_width,$midd_height);33     imagecopyresampled($bg_img,$footer,$foot_start_x , $foot_start_y,0,0,$foot_width,$foot_height,$foot_width,$foot_height);34     35     imagepng($bg_img,$save_path );36 }37 $head = dirname(__FILE__).‘/public/images/head.png‘;38 $midd = dirname(__FILE__).‘/public/images/midd1.png‘;39 $foot = dirname(__FILE__).‘/public/images/foot1.png‘;40 $save_path = dirname(__FILE__)."/public/images/testcomblie.png";41 combineImage($head,$midd,$foot,$save_path);

 

php合并圖片(轉)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.