PHP | imagecolorexactalpha() Function Last Updated : 06 Sep, 2018 Comments Improve Suggest changes Like Article Like Report The imagecolorexactalpha() function is an inbuilt function in PHP which is used to get the index of the specified color with alpha value. This function returns the index of the specified color and alpha value (RGBA value) in the palette of the image. Syntax: int imagecolorexactalpha ( $image, $red, $green, $blue, $alpha ) Parameters: This function accepts five 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. $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 returns the index of the specified color and alpha in the palette of the image on success, or -1 if the color does not exist in the image's palette. Below programs illustrate the imagecolorexactalpha() function in PHP: Program 1: php <?php // Setup an image $image = imagecreatefrompng( 'https://media.geeksforgeeks.org/wp-content/uploads/col1.png'); $colors = Array(); $colors[] = imagecolorexactalpha($image, 255, 0, 255, 0); $colors[] = imagecolorexactalpha($image, 0, 225, 146, 127); $colors[] = imagecolorexactalpha($image, 255, 56, 255, 55); $colors[] = imagecolorexactalpha($image, 100, 55, 252, 20); print_r($colors); // Free from memory imagedestroy($image); ?> Output: Array ( [0] => 16711935 [1] => 2130764178 [2] => 939473151 [3] => 342112252 ) Program 2: php <?php // Setup an image $image = imagecreatefrompng( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-9.png'); $colors = Array( imagecolorexactalpha($image, 255, 120, 255, 45), imagecolorexactalpha($image, 160, 25, 146, 127), imagecolorexactalpha($image, 255, 56, 55, 155), imagecolorexactalpha($image, 190, 155, 252, 200) ); print_r($colors); // Free from memory imagedestroy($image); ?> Output: Array ( [0] => 771717375 [1] => 2141198738 [2] => -1677772745 [3] => -927032324 ) Related Articles: PHP | imagecolorstotal() Function PHP | imagecolorset() Function PHP | imagecolorresolvealpha() Function Reference: http://php.net/manual/en/function.imagecolorexactalpha.php Comment More infoAdvertise with us Next Article PHP | imagecolorexactalpha() Function V vijay_raj Follow Improve Article Tags : Misc Web Technologies PHP Image-Processing PHP-function +1 More Practice Tags : Misc Similar Reads 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 | imagecolorallocatealpha() Function The imagecolorallocatealpha() function is an inbuilt function in PHP which is used to allocate the color for an image. This function is same as imagecolorallocate() function with addition of transparency parameter $alpha. This function accepts five parameters and returns color identifier on true or 3 min read PHP | imagecolorclosestalpha() Function The imagecolorclosestalpha() function is an inbuilt function in PHP which is used to get the index of closest color with alpha value 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 and alpha level. The alpha val 2 min read 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 | imagecolorresolvealpha() Function The imagecolorresolvealpha() function is an inbuilt function in PHP which is used to get the index of the specified color and alpha value or its closest possible alternative value. This function returns the index for a requested color, either the exact color or the closest possible alternative color 2 min read PHP | imagecolorset() Function 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 wi 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 | 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 | imagecolordeallocate() Function The imagecolordeallocate() function is an inbuilt function in PHP which is used to de-allocate a color created by imagecolorallocate() or imagecolorallocatealpha() function for an image. Syntax: bool imagecolordeallocate( $image, $color ) Parameters: This function accepts two parameters as mentioned 2 min read Like