PHP | imagecolorresolvealpha() Function Last Updated : 23 Aug, 2019 Comments Improve Suggest changes Like Article Like Report 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. Syntax: int imagecolorresolvealpha ( $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 value of colors. Below programs illustrate the imagecolorresolvealpha() function in PHP: Program 1: php <?php // Load an image $image = imagecreatefromgif( 'https://media.geeksforgeeks.org/wp-content/uploads/animateImages.gif'); // Get closest colors from the image $colors = array(); $colors[] = imagecolorresolvealpha($image, 156, 0, 255, 0); $colors[] = imagecolorresolvealpha($image, 0, 255, 200, 50); $colors[] = imagecolorresolvealpha($image, 16, 134, 35, 70); $colors[] = imagecolorresolvealpha($image, 143, 255, 254, 100); // Output print_r($colors); imagedestroy($image); ?> Output: Array ( [0] => 187 [1] => 188 [2] => 189 [3] => 190 ) Program 2: php <?php // Load an image $image = imagecreatefromgif( 'https://media.geeksforgeeks.org/wp-content/uploads/animateImages.gif'); // Get closest colors from the image $colors = array( imagecolorresolvealpha($image, 156, 0, 255, 0), imagecolorresolvealpha($image, 0, 255, 200, 50), imagecolorresolvealpha($image, 16, 134, 35, 70), imagecolorresolvealpha($image, 143, 255, 254, 100) ); // Output print_r($colors); imagedestroy($image); ?> Output: Array ( [0] => 187 [1] => 188 [2] => 189 [3] => 190 ) Related Articles: PHP | imagecolorclosestalpha() Function PHP | imagecolorclosest() Function Reference: http://php.net/manual/en/function.imagecolorresolvealpha.php Comment More infoAdvertise with us Next Article PHP | imagecolorresolvealpha() Function V vijay_raj Follow Improve Article Tags : Misc Web Technologies PHP Image-Processing PHP-function +1 More Practice Tags : Misc Similar Reads 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 | 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 | imagecolorexactalpha() Function 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, 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 | 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 Like