国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

php 圖片水印中文亂碼解決方法

2024-09-04 11:44:21
字體:
來源:轉載
供稿:網友

php 圖片水印中文亂碼解決方法是要轉入一款中文字體就以了,如果你在生成水印有中文時,又沒載入相關的字體的話,那中文肯定會是亂碼的,如果是英語字母那載不載入都沒關系,代碼如下:

  1. $name =  iconv("gb2312","utf-8",www.survivalescaperooms.com php粉絲網); 
  2. $font = 'simhei.ttf';//水印字體    
  3. $im = imagecreatefromjpeg("test.jpg");//載入圖片    
  4. $black = imagecolorallocate($im, 0, 0, 0);//設置顏色    
  5. imagettftext($im, 12, 0, 320, 84, $black$font$name);//打印水印    
  6. imagepng($im);//輸出圖片,如果要保存加個保存路徑和文件名,如imagepng($im,'test1.jpg');   //開源代碼Vevb.com 
  7. imagedestroy($im);//清空緩存  

下面來看一款生成水印文字函數,代碼如下:

  1. function str2pic ($string,$source,$destination="",$f,$fontsize=10,$shadowcolor="#ffffff",$f,$x=10,$y=10) {    
  2.  //header('content-type:image/png'); 
  3.     $pi=pathinfo($source); 
  4.     $pie=$pi[extension];#獲取擴展名 
  5.     if(eregi("jpg|jpeg",$pie))$im=@imagecreatefromjpeg($source); 
  6.     if(eregi("gif",$pie))$im=@imagecreatefromgif($source); 
  7.     if(eregi("png",$pie))$im=@imagecreatefrompng($source); 
  8.     $col1=hex2dec($shadowcolor);#陰影顏色 
  9.     $col2=hex2dec($fontcolor);#字體顏色 
  10.     $col1=imagecolorallocate($im,$col1[0],$col1[1],$col1[2]); 
  11.     $col2=imagecolorallocate($im,$col2[0],$col2[1],$col2[2]); 
  12.     imagettftext($im,$fontsize,0,$y+1,$x+1,$col1,$fonturl,$string); 
  13.     imagettftext($im,$fontsize,0,$y,$x,$col2,$fonturl,$string); 
  14.     imagejpeg($im); 
  15.     if($destination)imagejpeg($im,$destination); 
  16.     imagedestroy($im); 
  17.  
  18. function hex2dec($hexcolror) {#十六進制顏色轉換成10進制顏色 
  19.     preg_match_all("/([0-f]){2,2}/i",$hexcolror,$matches); 
  20.     if(count($matches[0])==3){ 
  21.     $rr=hexdec($matches[0][0]); 
  22.     $gg=hexdec($matches[0][1]); 
  23.     $bb=hexdec($matches[0][2]); 
  24.     } 
  25.     return array($rr,$gg,$bb); 
  26. ?> 
  27. <?php 
  28. str2pic("[url=http://www.survivalescaperooms.com]www.survivalescaperooms.com","winter.jpg","winter2.jpg","simhei.ttf",10,"ffffff","330099",10,10[/url]); 
  29. ?> 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 城步| 西吉县| 潞西市| 贵港市| 横山县| 万源市| 诸城市| 东阳市| 青龙| 屏山县| 谷城县| 榆社县| 广水市| 静乐县| 通山县| 建水县| 鸡泽县| 汉寿县| 双辽市| 天长市| 桂阳县| 茌平县| 宁明县| 中宁县| 桐梓县| 宣威市| 都江堰市| 永兴县| 金华市| 分宜县| 伊春市| 庄河市| 金寨县| 房山区| 德格县| 中卫市| 武平县| 浮山县| 金坛市| 江北区| 杭锦旗|