PHP | imagecolorset() Function Last Updated : 17 Jan, 2022 Comments Improve Suggest changes Like Article Like Report The imagecolorset() function is an inbuilt function in PHP which is used to set the color for the specified palette index. It is used to specify the index in the palette to the specified color. To perform the actual flood-fill, it is useful to create the flood-fill-like effects in palleted images without the overhead.Syntax: void imagecolorset ( $image, $index, $red, $green, $blue, $alpha ) 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.$index: This parameter is the index value in the palette 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.$alpha: This parameter is used to set the transparency of image. The value of $alpha lies between 0 to 127 where 0 represents completely opaque while 127 represents completely transparent. Return Value: This function does not return any value.Below programs illustrate the imagecolorset() function in PHP:Program 1: php <?php // Create an image of given size $image = imagecreate(500, 300); // Set the background imagecolorallocate($image, 0, 0, 0); // Get the color index for the background $bg = imagecolorat($image, 150, 100); // Change the background color imagecolorset($image, $bg, 0, 153, 0); // Output of the image header('Content-Type: image/png'); imagepng($image); imagedestroy($image); ?> Output: Program 2: php <?php // Create an image of given size $image = imagecreate(500, 300); // Set the background imagecolorallocate($image, 0, 0, 0); // set the colors of image $white_color = imagecolorallocate($image, 255, 255, 255); // draw the head imagearc($image, 200, 150, 200, 200, 0, 360, $white_color); // Get the color index for the background $bg = imagecolorat($image, 150, 100); // Set the background imagecolorset($image, $bg, 0, 153, 0); // Output the image to the browser header('Content-Type: image/png'); imagepng($image); imagedestroy($image); ?> Output: Related Articles: PHP | imagecolorclosest() FunctionPHP | imagecolorclosestalpha() FunctionPHP | imagecolorat() function Reference: http://php.net/manual/en/function.imagecolorset.php Comment More infoAdvertise with us Next Article PHP | imagecolorset() Function V vijay_raj Follow Improve Article Tags : Misc Web Technologies PHP Image-Processing PHP-function +1 More Practice Tags : Misc Similar Reads PHP | imagecolorat() function The imagecolorat() function is an inbuilt function in PHP which is used to get the index of the color of the pixel. This function returns the pixel value at the specified location.Syntax:Â Â int imagecolorat( $image, $x, $y ) Parameters: This function accepts three parameters as mentioned above and d 2 min read PHP | imagecolorexact() Function The imagecolorexact() function is an inbuilt function in PHP which is used to get the index of specified color in the palette of the image. In created image files only used colors in the image are resolved. Colors present only in the palette are not resolved. Syntax: int imagecolorexact ( $image, $r 2 min read PHP | imagecolorclosest() Function The imagecolorclosest() function is an inbuilt function in PHP which is used to get the index of the closest color in the given image. This function returns the index of the color in the palette of the image which is closest to the specified RGB value. Syntax: int imagecolorclosest( $image, $red, $g 2 min read PHP | imagecolorstotal() Function The imagecolorstotal() function is an inbuilt function in PHP which is used to find the number of colors in an image's palette. This function returns the number of colors in an image palette. Syntax: int imagecolorstotal ( $image ) Parameters: This function accepts a single parameter $image which is 1 min read PHP | imagecolorresolve() Function The imagecolorresolve() function is an inbuilt function in PHP which is used to get the index of the specified color or its closest possible alternative color. This function returns a color index value for a requested color, either the exact matched color or the closest possible alternative. Syntax: 2 min read PHP | imagecolormatch() Function The imagecolormatch() function is an inbuilt function in PHP which is used to make the color of palette version of an image more closely match the true color version. This function returns true on success or false on failure. Syntax: bool imagecolormatch ( $image1, $image2 ) Parameters: This functio 2 min read PHP | imagecolorclosesthwb() Function The imagecolorclosesthwb() function is an inbuilt function in PHP which is used to get the index of the color hue, white and blackness in the given image. This function returns an integer value with the index of the color which contains the hue, white and blackness nearest the given color. Syntax: i 2 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 | imagecolortransparent() Function The imagecolortransparent() function is an inbuilt function in PHP which is used to define color as transparent. It sets the color of a transparent image. It returns the identifier of the new transparent color. If an image has no transparent color and color not specified then it returns -1. Syntax: 2 min read PHP | imagecolorsforindex() Function The imagecolorsforindex() function is an inbuilt function in PHP which is used to get the colors at the given index. This function returns an array containing red, green, blue and alpha key values for specified color value.Syntax:Â Â array imagecolorsforindex ( $image, $index ) Parameters: This funct 2 min read Like