The imagecolorallocate() function is an inbuilt function in PHP which is used to set the color in an image. This function returns a color which is given in RGB format.
int imagecolorallocate ( $image, $red, $green, $blue )
Parameters: This function accepts four 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.
- $red: This parameter is used to set value of red color component.
- $green: This parameter is used to set value of green color component.
- $blue: This parameter is used to set value of blue color component.
Return Value: This function returns a color identifier on success or FALSE if the color allocation failed.
Below programs illustrate the imagecolorallocate() function in PHP.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.