PHP imagettftext() function
In this chapter you will learn:
- Description for PHP imagettftext() function
- Syntax for PHP imagettftext() function
- Parameters for PHP imagettftext() function
- Example - Draw text
Description
Writes the given text into the image using TrueType fonts.
Syntax
PHP imagettftext() function has the following syntax.
array imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text )
Parameters
- image - An image resource.
- size - The font size.
- angle - The angle in degrees, with 0 degrees being left-to-right reading text.
- x - The coordinates given by x and y will define the basepoint of the first character.
- y - The y-ordinate.
- color - The color index.
- fontfile - The path to the TrueType font.
Example
<?php/*j a v a 2 s.c o m*/
$image = imagecreate(400,300);
$blue = imagecolorallocate($image, 0, 0, 255);
$white = ImageColorAllocate($image, 255,255,255);
imagettftext($image, 44, 15, 50, 200, $white,"ARIAL", "java2s.com");
// Set the content-type
header("content-type: image/png");
imagepng($image);
imagedestroy($image);
?>
Next chapter...
What you will learn in the next chapter:
Home » PHP Tutorial » PHP Image Functions