php利用gd實現圖片的邊框

來源:互聯網
上載者:User

標籤:create   span   gif   圖片合并   img   display   efi   from   實現   

 1 <?php 2  3 //實現兩張圖片合并  並內圖片有一定的邊框 4  5 $file = ‘image/qr_1047.png‘; 6 $logo = ‘image/logo_1047.jpg‘; 7 $code = ‘image/ewr.png‘; 8  9 $file_info = getimagesize( $file );10 $fileTmp = imagecreatefrompng( $file );11 12 thmbPic( $logo,$file_info[0]*0.26 );13 thmbPic( $logo,$file_info[0]*0.26+6,3 );14 15 $logo_tmp = imagecreatefromjpeg( $logo );16 $info_logo = getimagesize( $logo );17 $y =$file_info[0] *0.36;18 imagecopymerge($fileTmp, $logo_tmp, $y, $y, 0, 0, $info_logo[0], $info_logo[1],100);19 imagepng($fileTmp,$code);20 21  function thmbPic($img,$x=0,$y=0){22         //擷取圖片資訊23         $info_logo = getimagesize( $img );24         //建立臨時圖片25         $img_tmp = imagecreatefromjpeg( $img );26         //建立真彩色圖片27         $img_thm = imagecreatetruecolor($x,$x);28         $color = imagecolorallocate($img_thm,255,255,255);29         imagecolortransparent($img_thm,$color);30         imagefill($img_thm,0,0,$color);31         //壓縮圖片32         if( $y==0 ){33             imagecopyresampled($img_thm, $img_tmp, $y, $y, 0, 0, $x, $x, $info_logo[0], $info_logo[0]);34         }else{35             imagecopy($img_thm, $img_tmp, $y, $y, 0, 0, $info_logo[0], $info_logo[0]);36         }37         //儲存圖片38         imagejpeg($img_thm,$img);39         //銷毀圖片40         imagedestroy( $img_tmp );41         imagedestroy( $img_thm );42     }
View Code

 

php利用gd實現圖片的邊框

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.