PHP Image createtruecolor( ) Function

Image createtruecolor( ) function is another inbuilt PHP function mainly used to create a new true-color image. The function returns the given image in a specific size. We need to define the width and height of the required image. Instead of the image createtruecolor( ) function, we can also use other creative functions like image create ( ), which is another alternative as it will return a different image quality.

Syntax


S.NoParameterDescriptionOptional / mandatory
1$ widthThis parameter is used to define the image's width that we want to display.Mandatory
2$ heightThis parameter is used to define the height of the image that we want to displaymandatory

The imagecreatetruecolor( ) function returns the resource identifier of an image on successful execution of the program and FALSE on a failed attempt.

Program 1: PHP program to display the basic use of imagecreatetruecolor ( ) function

Output

PHP Image createtruecolor( ) Function

Here in this program, we have declared various variables like $image to define the size of the image that we require, $background color to define the color of background we require, $text color to define the color of text we require. We have used the image string ( ) function to declare the string we want to display as an image. To display the output of the image, we have used an inbuilt PHP command header and imagepng to display on the browser.

Program 2: PHP program to display the use of imagecreatetruecolor ( ) function

Output

PHP Image createtruecolor( ) Function

Here in this program, we have declared various variables like $image to define the size of the image that we require, $background color to define the color of background we require, $text color to define the color of text we require. We have used the image string ( ) function to declare the string we want to display as an image. To display the output of the image, we have used an inbuilt PHP command header and imagepng to display on the browser.

Program 3: PHP program to display the use of imagecreatetruecolor ( ) function to draw a polygon

Output

PHP Image createtruecolor( ) Function

Here in this program, we have declared various variables like $image to define the size of the image that we require, $background color to define the color of background we require, $text color to define the color of text we require, an array $valuesto set the coordinates of the polygon we need to declare, and we have used image polygon ( ) function to display the polygon we want to display as an image, to display the output of the image we have used an inbuilt PHP command header and imagepng to display on browser.

Program 4: PHP program to display the use of imagecreatetruecolor ( ) function to draw a polygon

Output

PHP Image createtruecolor( ) Function

Here in this program, we have declared various variables like $image to define the size of the image that we require, $background color to define the color of background we require, $text color to define the color of text we require, an array $values to set the coordinates of the polygon we need to declare, and we have used image polygon ( ) function to display the polygon we want to display as an image, to display the output of the image we have used an inbuilt PHP command header and imagepng to display on browser.






Latest Courses