php用GD2生成文字图片的方法
PHP #gd2014-04-09 21:51
PHP的GD2处理图片功能非常强大,下面放一个简单的生成文字图片的例子。
<?php
//字体大小
$size = 30;
//字体类型,本例为宋体
$font ="C:/windows/fonts/simsun.ttc";
//显示的文字
$text = "http://yige.org";
//创建一个长为511高为111的空白图片
$img = imagecreate(511, 111);
//给图片分配颜色
imagecolorallocate($img, 0xff, 0xcc, 0xcc);
//设置字体颜色
$black = imagecolorallocate($img, 0, 0, 0);
//将ttf文字写到图片中
imagettftext($img, $size, 0, 100, 50, $black, $font, $text);
//发送头信息
header('Content-Type: image/gif');
//输出图片
imagegif($img);相关文章
- PHP面试题常见算法题 2014/04/09
- Linux下PHP Error Class 'SoapClient' not found解决方法 2014/04/09
- php输出缓冲技术应用实践 2014/04/09
- php结合js实现多文件上传 2014/04/09
- PHP最全防止sql注入的方法 2014/04/08
- php开发技巧 2014/04/08
- PHP中POSIX正则表达式介绍 2014/04/08
- CodeIgniter框架数据库备份的方法 2014/04/08
- PHP常用函数 2014/04/08
- php判断表单来源的方法 2014/04/08