First you need to enable php_gd2.dll in php.in (remove;)
extension=php_gd2.dll
Example code gd2.php:(you need to copy arial.ttf from C:/Windows/Fonts/ to the same directory of gd2.php)
<?php
$size = 30;
$font = 'arial.ttf';
$text = "jiansenlu.blogspot.com";
$img = imagecreate(600, 80);
imagecolorallocate($img, 0xff, 0xcc, 0xcc);
$black = imagecolorallocate($img, 0, 0, 0);
imagettftext($img, $size, 0, 100, 50, $black, $font, $text);
header('Content-Type: image/gif');
imagegif($img);
?>
$size = 30;
$font = 'arial.ttf';
$text = "jiansenlu.blogspot.com";
$img = imagecreate(600, 80);
imagecolorallocate($img, 0xff, 0xcc, 0xcc);
$black = imagecolorallocate($img, 0, 0, 0);
imagettftext($img, $size, 0, 100, 50, $black, $font, $text);
header('Content-Type: image/gif');
imagegif($img);
?>
Result: gd2.gif
No comments:
Post a Comment