PHP | imagettftext() Function Last Updated : 19 Feb, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The imagettftext() function is an inbuilt function in PHP which is used to write text to the image using TrueType fonts. Syntax: array imagettftext( resource $image, float $size, float $angle, int $x, int $y, int $color, string $fontfile, string $text) Parameters: This function accept eight parameters as mentioned above and described below: $image: It specifies the image to be worked upon. $size: It specifies the font size to use in points. $angle: It specifies the angle in degrees. $x: It specifies the x-coordinate. $y: It specifies the y-coordinate. $color: It specifies the index of the desired color for the text. $fontfile: It specifies the font to be used. $text: It specifies the text to write. Return Value: This function returns an array on success. Below examples illustrates the imagettftext() function in PHP. Example 1: php <?php // Create an empty image $im = imagecreatetruecolor(800, 250); // Add text using a font from local file $dataArr = imagettftext($im, 0, 0, 10, 10, imagecolorallocate($im, 0, 150, 0), './Pacifico.ttf', 'GeeksforGeeks'); // Output to browser print("<pre>" . print_r($dataArr, true) . "</pre>"); ?> Output: Array ( [0] => 8 [1] => 12 [2] => 18 [3] => 12 [4] => 18 [5] => 7 [6] => 8 [7] => 7 ) Example 2: php <?php // Create an empty image $im = imagecreatetruecolor(800, 250); // Add text using a font from local file imagettftext($im, 90, 0, 100, 100, imagecolorallocate($im, 0, 0, 255), './RugeBoogie-Regular.ttf', 'GeeksforGeeks'); // Output to browser header('Content-Type: image/png'); imagepng($im); imagedestroy($im); ?> Output: Reference: https://www.php.net/manual/en/function.imagettftext.php Comment More infoAdvertise with us Next Article PHP | imagettfbbox() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-image-functions Similar Reads PHP | imagefttext() Function The imagefttext() function is an inbuilt function in PHP which is used write text to the image using fonts using FreeType 2. Syntax: array imagefttext( resource $image, float $size, float $angle, int $x, int $y, int $color, string $fontfile, string $text, array $extrainfo ) Parameters: This function 2 min read PHP | imagettfbbox() Function The imagettfbbox() function is an inbuilt function in PHP that is used to calculate the bounding box in pixels for a TrueType text.Syntax:Â Â array imagettfbbox( float $size, float $angle, string $fontfile, string $text) Parameters: This function accepts four parameters as mentioned above and describ 2 min read PHP | imageftbbox() Function The imageftbbox() function is an inbuilt function in PHP which is used to calculate the bounding box of a text using fonts via freetype2. Syntax: array imageftbbox( float $size, array $angle, string $fontfile, string $text, array $extrainfo ) Parameters: This function accept five parameters as menti 2 min read PHP | imagesx() Function The imagesx() function is an inbuilt function in PHP which is used to return the width of the given image. Syntax: int imagesx( $image ) Parameters: This function accepts single parameters $image which is mandatory. This $image variable can store the image created by imagecreatetruecolor() image cre 1 min read PHP | imagesettile() Function The imagesettile() function is an inbuilt function in PHP which is used to set the tile image for filling the area. Syntax: bool imagesettile( $image, $tile ) Parameters: This function accepts two parameters as mentioned above and described below: $image: It is returned by one of the image creation 2 min read PHP | imagexbm() Function The imagexbm() function is an inbuilt function in PHP which is used to display image to browser a file. The main use of this function is to view an image in the browser and convert any other image type to XBM. Syntax: bool imagexbm( resource $image, int $to, int $foreground) Parameters: This functio 2 min read Like