Get the index of the specified color + alpha in PHP

Description

The following code shows how to get the index of the specified color + alpha.

Example


<?php//from  w w w. j av a  2 s  .  co m

// Setup an image
$im = imagecreatefrompng('./test.png');

$colors   = Array();
$colors[] = imagecolorexactalpha($im, 255, 0, 0, 0);
$colors[] = imagecolorexactalpha($im, 0, 0, 0, 127);
$colors[] = imagecolorexactalpha($im, 255, 255, 255, 55);
$colors[] = imagecolorexactalpha($im, 100, 255, 52, 20);

print_r($colors);

// Free from memory
imagedestroy($im);
?>

The code above generates the following result.

Get the index of the specified color + alpha in PHP




















Home »
  PHP Tutorial »
    Image »




Color
Create
Font
Operation
Shape
Text