PHP Imagecolorresolve () Function

PHP

Syntax:
int imagecolorresolve ($image, $red, $green, $blue)
Parameters:This function takes four parameters as above and described below:
  • $image:is returned by one of the image creation functions such as imagecreatetruecolor(). Used to create the size of the image.
  • $red:This parameter is used to set the red component value.
  • $green:this parameter is used to set the value of the component to green.
  • $blue:this parameter is used to set the value of the component to blue.
Return value:this function returns the color index.The following programs illustrate the imagecolorresolve() functionin PHP:Program 1 :  
// Upload image $image = imagecreatefromgif ( ' https://media.engineerforengineer.org/wp-content/uploads/animateImages.gif ' );  
// Get the closest colors from the image $colors = array (); $colors [] = imagecolorresolve ( $image , 167, 75, 55); $colors [] = imagecolorresolve ( $image , 150, 25, 250); $colors [] = imagecolorresolve ( $image , 161, 234, 135); $colors [] = imagecolorresolve ( $image , 143, 255, 254);  
// Exit print_r ( $colors ); imagedestroy ( $image ); ?>
Output:
Array ([0] = > 187 [1] = > 188 [2] = > 189 [3] = > 190)
Program 2:  
// Upload image $image = imagecreatefrompng ( ' https://media.engineerforengineer.org/wp-content/uploads/col1.png ' );  
// Get the closest colors from the image $colors = array ( imagecolorresolve ( $image , 156, 0, 255), imagecolorresolve ( $image , 0, 255, 200), imagecolorresolve ( $image , 16, 134, 35), imagecolorresolve ( $image , 143, 255, 254) );  
// Exit print_r ( $colors ); imagedestroy ( $image ); ?>
Output:
Array ([0] = > 10223871 [1] = > 65480 [2] = > 1082915 [3] = > 9437182)
Related Articles: < / strong>
  • PHP | Imagecolorallocate() function
  • PHP | Imagearc() function
Link: http://php.net/manual/en/function.imagecolorresolve.php