PHP | imagestring() Function Last Updated : 17 Aug, 2018 Comments Improve Suggest changes Like Article Like Report The imagestring() function is an inbuilt function in PHP which is used to draw the string horizontally. This function draws the string at given position. Syntax: bool imagestring( $image, $font, $x, $y, $string, $color ) Parameters: This function accepts six parameters as mentioned above and described below: $image: The imagecreatetruecolor() function is used to create a blank image in a given size. $font: This parameter is used to set the font size. Inbuilt font in latin2 encoding can be 1, 2, 3, 4, 5 or other font identifiers registered with imageloadfont() function. $x: This parameter is used to hold the x-coordinate of the upper left corner. $y: This parameter is used to hold the y-coordinate of the upper left corner. $string: This parameter is used to hold the string to be written. $color: This parameter is used to hold the color of image. Return Value: This function returns TRUE on success or FALSE on failure. Below programs illustrate the imagestring() function in PHP. Program 1: php <?php // Create the size of image or blank image $image = imagecreate(500, 300); // Set the background color of image $background_color = imagecolorallocate($image, 0, 153, 0); // Set the text color of image $text_color = imagecolorallocate($image, 255, 255, 255); // Function to create image which contains string. imagestring($image, 5, 180, 100, "GeeksforGeeks", $text_color); imagestring($image, 3, 160, 120, "A computer science portal", $text_color); header("Content-Type: image/png"); imagepng($image); imagedestroy($image); ?> Output: Program 2: php <?php // Create the size of image or blank image $image = imagecreate(500, 300); // Set the background color of image $background_color = imagecolorallocate($image, 255, 255, 255); // Set the text color of image $text_color = imagecolorallocate($image, 0, 153, 0); // Function to create image which contains string. imagestring($image, 5, 50, 100, "GeeksforGeeks: A computer science portal", $text_color); header("Content-Type: image/png"); imagepng($image); imagedestroy($image); ?> Output: Related Articles: PHP | imagedashedline() Function PHP | imagecolorat() function PHP | imagepolygon() Function Reference: http://php.net/manual/en/function.imagestring.php Comment More infoAdvertise with us Next Article PHP | imagestring() Function V vijay_raj Follow Improve Article Tags : Misc Web Technologies PHP PHP-function Practice Tags : Misc Similar Reads PHP | imagestringup() Function The imagestringup() function is an inbuilt function in PHP which is used to draw a string vertically. Syntax: bool imagestringup( $image, $font, $x, $y, $string, $color ) Parameters: This function accepts six parameters as mentioned above and described below: $image: The imagecreatetruecolor() funct 2 min read PHP | imagepng() Function The imagepng() function is an inbuilt function in PHP which is used to display image to browser or file. The main use of this function is to view an image in the browser, convert any other image type to PNG and applying filters to the image. Syntax: bool imagepng( resource $image, int $to, int $qual 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 | imagegd() function The imagegd() function is an inbuilt function in PHP which is used to output GD image to browser or file. This is most useful to convert any other image type to gd. imagecreatefromgd() function can be used to further read gd images. Syntax: bool imagegd( resource $image, float $to) Parameters:This 2 min read Like