最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
用PHP产生动态的影像图[转自奥索]
时间:2008-01-12 编辑:简简单单 来源:一聚教程网
我用 TTF 字型在以下的范例中
我通常取名作 'button.php3':
#######################################################
-----button.php3------
Header("Content-type: image/gif");
if(!isset($s)) $s=11;
$size = imagettfbbox($s,0,"fonts/TIMES.TTF",$text);
$dx = abs($size[2]-$size[0]);
$dy = abs($size[5]-$size[3]);
$xpad=9;
$ypad=9;
$im = imagecreate($dx+$xpad,$dy+$ypad);
$blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black, "fonts/TIMES.TTF", $text);
ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white, "fonts/TIMES.TTF", $text);
ImageGif($im);
ImageDestroy($im);
?>
#######################################################
很重要一点是你不能在这档案中放任何HTML tags.也不能有空白行在 tag 之前或之後. 如果你用这段Script後看到一个不完整的影像, 表示你可能在PHP标签以外误打了字元.
以上的 script 可以由此语法在网页中叫出来:
#######################################################
-
上一个: PHP中利用GD输出汉字实例
-
下一个: 缩略图生成的php程序[转自奥索]
相关文章
- 用PHP将Unicode 转化为UTF-8的实现方法 03-21
- php实现36进制与10进制转换功能示例 01-11
- PHP中把stdClass Object对象转array的几个方法 06-13
- php四则运算:中缀表达式转后缀表达式例子 02-05
- PHP大转盘中奖概率算法与示例代码 09-03
- php农历转阳历实现代码 01-18