php如何給圖片添加浮水印的案例

來源:互聯網
上載者:User
這篇文章主要為大家分享了一段php圖片添加浮水印例子,具有一定的參考價值,感興趣的小夥伴們可以參考一下

圖片添加浮水印我相信各位朋友都知道的,今天我們來看一段php的圖片添加浮水印例子,希望文章能夠協助到各位朋友。

<?php   /**    * 圖片添加浮水印    * $target 源檔案路徑    * $wtrmrk_file 浮水印圖片路徑    * $newcopy 添加浮水印後的圖片路徑    *    */   public function watermark_image($target, $wtrmrk_file, $newcopy) {     $watermark = imagecreatefrompng($wtrmrk_file);     imagealphablending($watermark, false);     imagesavealpha($watermark, true);     $img = imagecreatefromjpeg($target);     $img_w = imagesx($img);     $img_h = imagesy($img);     $wtrmrk_w = imagesx($watermark);     $wtrmrk_h = imagesy($watermark);     $dst_x = ($img_w ) – ($wtrmrk_w); // For centering the watermark on any image //phpfensi.com     $dst_y = ($img_h) – ($wtrmrk_h ); // For centering the watermark on any image     imagecopy($img, $watermark, $dst_x, $dst_y, 0, 0, $wtrmrk_w, $wtrmrk_h);          imagejpeg($img, $newcopy, 100);     imagedestroy($img);     imagedestroy($watermark);     //return $img;   } ?>

總結:以上就是本篇文的全部內容,希望能對大家的學習有所協助。

聯繫我們

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