為什么是亂碼?
<?php
//打開圖片
//1.配置圖片路徑
$src = '06.jpg';
//2.獲取圖片信息
$info = getimagesize($src);
//echo '<pre>';
//print_r($info);
//3通過圖像編號(hào)獲取圖像類型
$type = image_type_to_extension($info[2],false);
//print_r($type);
//4在內(nèi)存中創(chuàng)建一個(gè)和我們圖像類型一樣的圖像
$fun = "imagecreatefrom{$type}";
//5把圖片復(fù)制到內(nèi)存中
$image=$fun($src);
//操作圖片
//1設(shè)置字體路徑
$font = "wei.ttf";
//2填寫水印內(nèi)容
$content = "你好,慕課";
//3設(shè)置字體的顏色和透明度
$col = imagecolorallocatealpha($image,255,0,0,50);
//4寫入文字
imagettftext($image,20,0,20,30,$col,$font,$content); ?
//輸出圖片
//1瀏覽器輸出
header("Content-type:".$info['mime']);
$func = "image{$type}";
$func($image);
//保存圖片
?>
2016-03-05
編碼工具的編碼格式要和瀏覽器的編碼格式對(duì)應(yīng)。