PHP GD imagettftext

This example shows how to display imagettftext in php gd.

 
 

Share on Google+Share on Google+

PHP GD imagettftext

Ads

This example shows how to display imagettftext in php gd.

<?php

header('Content-type: image/png');

$im = imagecreatetruecolor(400, 30);

$white = imagecolorallocate($im, 255, 255, 255);

$grey = imagecolorallocate($im, 128, 128, 128);

$black = imagecolorallocate($im, 0, 0, 0);

imagefilledrectangle($im, 0, 0, 399, 29, $white);

$text = 'This is imagettftext';

$font = 'C:/WINNT/Fonts/arial.ttf';

imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);

imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

imagepng($im);

imagedestroy($im);

?>

After running the program you will get the following output

Advertisements

Ads

Posted on: November 10, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles