php給圖片加文字浮水印,_PHP教程

來源:互聯網
上載者:User

php給圖片加文字浮水印,


注釋非常的詳細了,這裡就不多廢話了

<?php/*給圖片加文字浮水印的方法*/$dst_path = 'http://f4.topitme.com/4/15/11/1166351597fe111154l.jpg';$dst = imagecreatefromstring(file_get_contents($dst_path));/*imagecreatefromstring()--從字串中的映像流建立一個映像,返回一個映像標示符,其表達了從給定字串得來的映像映像格式將自動監測,只要php支援jpeg,png,gif,wbmp,gd2.*/ $font = './t1.ttf';$black = imagecolorallocate($dst, 0, 0, 0);imagefttext($dst, 20, 0, 10, 30, $black, $font, 'Hello world!');/*imagefttext($img,$size,$angle,$x,$y,$color,$fontfile,$text)$img由映像建立函數返回的映像資源size要使用的浮水印的字型大小angle(角度)文字的傾斜角度,如果是0度代表文字從左往右,如果是90度代表從上往下x,y浮水印文字的第一個文字的起始位置color是浮水印文字的顏色fontfile,你希望使用truetype字型的路徑*/list($dst_w,$dst_h,$dst_type) = getimagesize($dst_path);/*list(mixed $varname[,mixed $......])--把數組中的值賦給一些變數像array()一樣,這不是真正的函數,而是語言結構,List()用一步操作給一組變數進行賦值*//*getimagesize()能擷取到什麼資訊?getimagesize函數會返回映像的所有資訊,包括大小,類型等等*/switch($dst_type){  case 1://GIF    header("content-type:image/gif");    imagegif($dst);    break;  case 2://JPG    header("content-type:image/jpeg");    imagejpeg($dst);    break;  case 3://PNG    header("content-type:image/png");    imagepng($dst);    break;  default:    break;  /*imagepng--以PNG格式將映像輸出到瀏覽器或檔案  imagepng()將GD映像流(image)以png格式輸出到標註輸出(通常為瀏覽器),或者如果用filename給出了檔案名稱則將其輸出到檔案*/}imagedestroy($dst);?>

以上所述就是本文的全部內容了,希望大家能夠喜歡。

http://www.bkjia.com/PHPjc/1041325.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1041325.htmlTechArticlephp給圖片加文字浮水印, 注釋非常的詳細了,這裡就不多廢話了 php/*給圖片加文字浮水印的方法*/$dst_path = 'http://f4.topitme.com/4/15/11/1166351597fe11...

  • 聯繫我們

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