Home Tutorial Php Phpgd PHP GD draw text

 
 

PHP GD draw text
Posted on: November 4, 2009 at 12:00 AM
Advertisement
This example shows how to draw text 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 = 'Roseindia...';

$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

Advertisement

Related Tags for PHP GD draw text:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 4, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com