<?php
// 设置图象的尺寸
$height = 17;
$width = 47;
$im = ImageCreateTrueColor($width, $height);
$white = ImageColorAllocate ($im, 255, 255, 255);
$blue = ImageColorAllocate ($im, 92, 146, 245);
// draw on image
ImageFill($im, 0, 0, $blue);
//ImageLine($im, 0, 0, $width, $height, $white);
$str=strtoupper(substr(md5(rand(0,100000)),0,5));
session_start();
$_SESSION["yanzheng"]=$str;
$yan=ImageString($im, 10, 3, 2, $_SESSION['yanzheng'], $white);
for($i=0;$i<200;$i++) //加入干扰象素
{
$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
}
// 输出图象
Header ('Content-type: image/png');
ImagePng ($im);
// clean up
ImageDestroy($im);
?>