imagecolorresolvealpha() function in PHP


The imagecolorresolvealpha() function is used to get the index of the specified color with alpha.

Syntax

imagecolorresolvealpha (img , red , green , blue , alpha )

Parameters

  • img: Creates an image with imagecreatetruecolor().

  • red: The red component

  • green: The green component

  • blue: The blue component

  • alpha: Value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.

Return

The imagecolorresolvealpha() function returns the color index.

Example

The following is an example

 Live Demo

<?php
   $img = imagecreatefromgif('https://www.tutorialspoint.com/images/html.gif');
   $colors = array();
   $colors[] = imagecolorresolvealpha($img, 120, 0, 190,0);
   $colors[] = imagecolorresolvealpha($img, 110, 0, 140,0);
   $colors[] = imagecolorresolvealpha($img, 120, 190, 0,0);
   print_r($colors);
   imagedestroy($img);
?>

Output

The following is the output:

Array ( [0] => 128 [1] => 129 [2] => 130 )

Updated on: 31-Dec-2019

15 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements