PHP code to write string on image using specified TTF font

by rajesh 2012-10-16 17:45:44

The following part of code can be used to write a string on a image using a specified TTF font

The main function is imagettftext. In this example we have used tahoma.ttf, you can use any ttf file, either have that ttf font in the same folder where the code file exists or use full path for $font.

--------------------------------------------------------------------
$im2 = imagecreate($width, $height);
$left = 10;
$top = 10;
$col = imageColorAllocate($im2, 0,0,255); //blue color
$char = "HIOX";
$font="tahoma.ttf";
imagettftext($im2, $fontsize, 0, $left, $top, $col, $font, $char);
--------------------------------------------------------------------
834
like
0
dislike
0
mail
flag

You must LOGIN to add comments