php如何?圖片合成並產生浮水印(完整代碼)

來源:互聯網
上載者:User
本篇文章給大家帶來的內容是關於php如何?圖片合成並產生浮水印(完整代碼),有一定的參考價值,有需要的朋友可以參考一下,希望對你有所協助。

<?php$dst_path ='./upload/goods/2018/06-04/2bd2518a2e4e6d8bdab9f01434b9f754.png';$src_path = './public/upload/weixin/20180620/a643cf1ee7dd5bda12270647ca543f60.png';$hz = substr(strrchr($dst_path, '.'), 1);$image = date("YmdHis").rand(100000,999999).".".$hz;//建立圖片的執行個體$dst = imagecreatefromstring(file_get_contents($dst_path));$src = imagecreatefromstring(file_get_contents($src_path));//擷取浮水印圖片的寬高$src_w =139;$src_h=58;list($src_w,$src_h) = getimagesize($src_path);//如果浮水印圖片本身帶透明色,則使用imagecopy方法imagecopy($dst, $src, 85,85, 0, 0, $src_w, $src_h);//輸出圖片list($src_w, $src_h, $dst_type) = getimagesize($dst_path);switch ($dst_type) {    case 1://GIF        header('Content-Type: image/gif');        imagegif($dst,".".$image);                break;        case 2://JPG        header('Content-Type: image/jpeg');         imagejpeg($dst,".".$image);         break;     case 3://PNG         header('Content-Type: image/png');         imagepng($dst,".".$image);         break;     default:         break;} imagedestroy($dst); imagedestroy($src); return $image;

聯繫我們

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