php imagecreatetruecolor输出字符符或验证码

$img = imagecreatetruecolor(100,100);    //创建真彩图像资源 
$color = imagecolorAllocate($img,200,200,200);   //分配一个灰色 
imagefill($img,0,0,$color);                 // 从左上角开始填充灰色 
header('content-type:image/jpeg');   //jpg格式 
imagejpeg($img); 

 //显示灰色的方块 

 

 

例二:

imagestring

 

<?php
// 建立一幅 100X30 的图像
$im = imagecreate(100, 30);

// 白色背景和蓝色文本
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// 把字符串写在图像左上角
imagestring($im, 5, 0, 0, "Hello world!", $textcolor);

// 输出图像
header("Content-type: image/png");
imagepng($im);
?>

  

 

 

posted @ 2015-07-08 11:02  穆晟铭  阅读(743)  评论(0编辑  收藏  举报