最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php技術(shù)實現(xiàn)加載字體并保存成圖片

 更新時間:2015年07月27日 17:55:07   作者:柒捌玖零  
這篇文章主要介紹了php技術(shù)實現(xiàn)加載字體并保存成圖片,需要的朋友可以參考下
下面通過一段代碼給大家詳解介紹下php技術(shù)實現(xiàn)加載字體并保存成圖片。


// Set the content-type 
header("Content-type: image/png"); 
 
// Create the image 
$im = imagecreatetruecolor(400, 100); 
 
// Create some colors 
$white = imagecolorallocate($im, 255, 255, 255); 
$grey = imagecolorallocate($im, 128, 128, 128); 
$black = imagecolorallocate($im, 0, 0, 0); 
imagefilledrectangle($im, 0, 0, 399, 100, $white); 
 
// The text to draw 
$text = '字典網(wǎng)'; 
// Replace path by your own font path 
$font = 'fontName.ttf'; 
 
// Add some shadow to the text 
//imagettftext($im, 60, 0, 11, 21, $grey, $font, $text); 
 
// Add the text 
imagettftext($im, 60, 0, 0, 70, $black, $font, $text); 
 
// Using imagepng() results in clearer text compared with imagejpeg() 
imagepng($im); 
imagedestroy($im); 
 


如果想保存圖可以用下面代碼

ob_start();  
  imagejpeg($im); 
$img = ob_get_contents();  
ob_end_clean();  
$size = strlen($img);  
  
$fp2=@fopen('tst.jpg', "a");  
fwrite($fp2,$img);  
fclose($fp2);  

以上代碼就可以完成加載字體并保存成圖片,希望大家會喜歡

相關(guān)文章

最新評論

黄平县| 甘洛县| 澄迈县| 若羌县| 合川市| 翁源县| 兴安盟| 伊川县| 兴和县| 锡林浩特市| 都安| 香河县| 衡东县| 阜阳市| 朝阳区| 长宁区| 镇雄县| 尚志市| 义乌市| 繁峙县| 于田县| 买车| 即墨市| 南部县| 城口县| 重庆市| 常州市| 安溪县| 泸西县| 二连浩特市| 新民市| 浦北县| 江阴市| 沙河市| 邹城市| 嘉祥县| 游戏| 肥东县| 内乡县| 遂宁市| 哈巴河县|