PHP | imagechar() Function Last Updated : 23 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The imagechar() function is an inbuilt function in PHP which is used to draw a character horizontally. This function draws the first character of string in the image identified by image with its x and y-axis. The coordinate of the top-left corner is (0, 0). Syntax: bool imagechar( $image, $font, $x, $y, $c, $color ) Parameters: This function accepts six parameters as mentioned above and described below: $image: It is returned by one of the image creation functions, such as imagecreatetruecolor(). It is used to create size of image. $font: This parameter is used to set font size of character. Its value can be 1, 2, 3, 4, 5 for built-in fonts in latin2 encoding. The higher numbers represents the larger fonts and small number represent small font. $x: This parameter is used to set x-coordinate to print character in image. $y: This parameter is used to set y-coordinate to print character in image. $c: The character which is printed. $color: It sets the color of image. A color identifier created by imagecolorallocate() function. Return Value: This function returns true on success or false on failure. Below programs illustrate the imagechar() function in PHP: Program 1: php <?php // Creates image size $image = imagecreate(400, 300); $string = 'GeeksForGeeks'; // Set background color $bg = imagecolorallocate($image, 0, 153, 0); // Set text color. $white = imagecolorallocate($image, 255, 255, 255); // Prints a white G character imagechar($image, 5, 190, 150, $string, $white); header('Content-type: image/png'); imagepng($image); ?> Output: Program 2: php <?php // Create image size $image = imagecreate(400, 300); $string = 'GeeksforGeeks'; // Find string length $len = strlen($string); // Set background color $bg = imagecolorallocate($image, 0, 153, 0); // Set text color $white = imagecolorallocate($image, 255, 255, 255); for($i = 0; $i < $len; $i++) // Prints white character of string using loop imagechar($image, 6, 190 + 10 * $i, 150, $string[$i], $white); header('Content-type: image/png'); imagepng($image); ?> Output: Related Articles: PHP | imagestring() Function PHP | imagecreate() Function Reference: http://php.net/manual/en/function.imagechar.php Comment More infoAdvertise with us Next Article PHP | imagechar() Function V vijay_raj Follow Improve Article Tags : Misc Web Technologies PHP PHP-function Practice Tags : Misc Similar Reads PHP | imagecharup() Function The imagecharup() function is an inbuilt function in PHP which is used to draw a character vertically. This function draws the first character of a string in the image identified by the image with its x and y-axis. The coordinate of the top-left corner is (0, 0). Syntax: bool imagecharup( $image, $f 2 min read PHP | imagearc() Function The imagearc() function is an inbuilt function in PHP which is used to create an arc of a circle centered at the given coordinates. This function returns true on success or false on failure. Syntax: bool imagearc( $image, $cx, $cy, $width, $height, $start, $end, $color ) Parameters: This function ac 3 min read PHP | imagecrop() Function The imagecrop() function is an inbuilt function in PHP which is used to crop an image to the given rectangle. This function crops an image to the given rectangular area and returns the resulting image. The given image is not modified. Syntax: resource imagecrop ( $image, $rect ) Parameters: This fun 1 min read PHP | imagecreate() Function The imagecreate() function is an inbuilt function in PHP which is used to create a new image. This function returns the blank image of given size. In general imagecreatetruecolor() function is used instead of imagecreate() function because imagecreatetruecolor() function creates high quality images. 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 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 | imagesy() Function The imagesy() function is an inbuilt function in PHP which is used to return the height of the given image. Syntax: int imagesy( $image ) Parameters: This function accepts single parameters $image which is mandatory. This $image variable store the image created by imagecreatetruecolor() image creati 1 min read PHP | imagecopy() Function The imagecopy() function is an inbuilt function in PHP which is used to copy the image or part of image. This function returns true on success or false on failure. Syntax: bool imagecopy ( $dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h ) Parameters: This function accepts eigh 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 | 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