<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>图片测试</title> </head> <body> <img src="test.php?text=井冈山报"> </body></html>
<?php //$text=$_REQUEST["text"];//显示的文字 $text="井冈山报"; $size=30;//字体大小 $font="c:/windows/fonts/SIMHEI.TTF";//字体类型,这里为黑体,具体请在windows/fonts文件夹中,找相应的font文件 $img=imagecreate(200,50);//创建一个长为500高为16的空白图片 imagecolorallocate($img,0xff,0xff,0xff);//设置图片背景颜色,这里背景颜色为#ffffff,也就是白色 $black=imagecolorallocate($img,0xff0000,0xff0000,0xff0000);//设置字体颜色,这里为#000000,也就是黑色 imagettftext($img,$size,0,0,38,$black,$font,$text);//将ttf文字写到图片中 header('Content-Type: image/png');//发送头信息 imagepng($img);//输出图片,输出png使用imagepng方法,输出gif使用imagegif方法 ?>
大牛,别默默的看了,快登录下载一个试试吧!:)
登录 立即注册