GD2输出图像

一 代码

<?php
// Set the content-type
header('Content-Type: image/png');
//header('content-type:text/html; charset=gb2312');
// Create the image
$im = imagecreatetruecolor(400, 30);
// Create some colors
$white = imagecolorallocate($im, 0, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font ='C:\Windows\Fonts\ariblk.ttf';             //注意这个地方路径一定要写正确
// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?> 

 

二 运行结果

 

猜你喜欢

转载自cakin24.iteye.com/blog/2375215
今日推荐