PHP Image Watermark Chinese garbled solution is to be transferred to a Chinese font in Morocco, if you create a watermark in Chinese, and did not load the relevant font, then the Chinese will certainly be garbled, if it is the English letter load does not matter oh.
PHP Tutorial Picture watermark Chinese garbled solution is to be transferred to a Chinese font in Morocco, if you create a watermark in Chinese, and did not load the relevant font, then the Chinese will certainly be garbled, if it is the English letter that load does not matter oh.
$name = Iconv ("gb2312", "Utf-8", www.bKjia.c0m-poly tutorial net);
$font = ' Simhei.ttf ';//Watermark Font
$im = Imagecreatefromjpeg ("test.jpg");//Load Picture
$black = imagecolorallocate ($im, 0, 0, 0);//Set color
Imagettftext ($im, 0, $black, $font, $name);//Print watermark
Imagepng ($im);//Output picture, if you want to save add a save path and file name, such as Imagepng ($im, ' test1.jpg ');
Imagedestroy ($im);//Empty Cache
Let's take a look at the Generate Watermark text function
Function Str2pic ($string, $source, $destination = "", $f, $fontsize =10, $shadowcolor = "#ffffff", $f, $x =10, $y =10) {
Header (' content-type:image/png ');
$pi =pathinfo ($source);
$pie = $pi [extension]; #获取扩展名
if (eregi ("Jpg|jpeg", $pie)) $im = @imagecreatefromjpeg ($source);
if (Eregi (" GIF ", $pie)) $im = @imagecreatefromgif ($source);
if (eregi ("PNG", $pie)) $im = @imagecreatefrompng ($source);
$col 1=hex2dec ($shadowcolor); #阴影颜色
$col 2=hex2dec ($fontcolor); #字体颜色
$col 1=imagecolorallocate ($im, $col 1 [0], $col 1[1], $col 1[2]);
$col 2=imagecolorallocate ($im, $col 2[0], $col 2[1], $col 2[2]);
Imagettftext ($im, $fontsize, 0, $y +1, $x +1, $col 1, $fonturl, $string);
Imagettftext ($im, $fontsize, 0, $y, $x, $col 2, $fonturl, $string);
Imagejpeg ($im);
if ($destination) imagejpeg ($im, $destination);
Imagedestroy ($im);
}
function Hex2dec ($hexcolror) {#十六进制颜色转换成10进制颜色
Preg_match_all ("/([0-f]) {2,2}/i", $hexcolror, $matches);
if (count ($matches [0]) ==3) {
$RR =hexdec ($matches [0][0]);
$gg =hexdec ($matches [0][1]);
$BB =hexdec ($matches [0][2]);
}
Return Array ($RR, $gg, $BB);
}
?>
Str2pic ("[url=http://www.zhutiai.com]www.bkjia.c0m", "winter.jpg", "winter2.jpg", "Simhei.ttf", Ten, "ffffff", " 330099 ", 10,10[/url]);
?>
http://www.bkjia.com/PHPjc/633028.html www.bkjia.com true http://www.bkjia.com/PHPjc/633028.html techarticle PHP Image Watermark Chinese garbled solution is to be transferred to a Chinese font in Morocco, if you create a watermark in Chinese, and did not load the relevant font, then the Chinese will certainly be ...