php給圖片加文字浮水印與圖片浮水印代碼(1/3)_PHP教程

來源:互聯網
上載者:User
php給圖片加文字浮水印與圖片浮水印代碼這款程式給圖片加文字浮水印時是調用 了C:\\WINDOWS\\Fonts\\SIMHEI.TTF字型,給圖片加浮水印時就可以自定圖片哦。

php教程給圖片加文字浮水印與圖片浮水印代碼
這款程式給圖片加文字浮水印時是調用 了c:windowsfontssimhei.ttf字型,給圖片加浮水印時就可以自定圖片哦。
$image->wprint_img();//執行圖片浮水印
$image->wprint_string();//執行文字浮水印
*/

class editimage{
private $imagefile;//圖片檔案
private $smallimg;//浮水印圖片
private $string;//浮水印文字
private $position;//存放位置
private $dst_x=600;//原始圖片打浮水印x座標
private $dst_y=0;//原始圖片打浮水印y座標
private $str_x=450;
private $str_y=200;
private $font="c:windowsfontssimhei.ttf";//原始圖片打浮水印字型路徑
private $imgej;// imagecolorallocate後的變數

function __get($value){
return $this->$value;
}
function __set($property,$value){
$this->$property=$value;
}
/**
* 建構函式初始化
*
* @param string $imagefile 被上浮水印的檔案
* @param string $smallimg 浮水印檔案
* @param string $string 浮水印文字
* @param string $position 存放位置
* @param int $dst_x 被上浮水印的圖片x
* @param int $dst_y 被上浮水印的圖片y
*/
function __construct($imagefile,$smallimg='',$string=''){//,$position='',$dst_x=0,$dst_y=0
$this->imagefile=$imagefile;
$this->smallimg=$smallimg;
$this->string=$string;
$this->imgej=$this->imagecreatef($this->imagefile);
}

function get_extname($file){//擷取檔案的尾碼名
if (file_exists($this->imagefile)) {
$img=getimagesize($file);
switch ($img[2]){
case "1":
return "gif";
case "2":
return "jpg";
case "3":
return "png";
}
}else{
return false;
}
}

1 2 3

http://www.bkjia.com/PHPjc/633042.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/633042.htmlTechArticlephp給圖片加文字浮水印與圖片浮水印代碼這款程式給圖片加文字浮水印時是調用 了C:\\WINDOWS\\Fonts\\SIMHEI.TTF字型,給圖片加浮水印時就可以自定圖片哦...

  • 聯繫我們

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