Get the index of the specified color or its closest possible alternative in PHP

Description

The following code shows how to get the index of the specified color or its closest possible alternative.

Example


<?php//from   w  ww.  java  2s  .co  m
// Load an image
$im = imagecreatefromgif('./test.gif');

// Get closest colors from the image
$colors = array();
$colors[] = imagecolorresolve($im, 255, 255, 255);
$colors[] = imagecolorresolve($im, 0, 0, 200);

// Output
print_r($colors);

imagedestroy($im);
?>

The code above generates the following result.

Get the index of the specified color or its closest possible alternative in PHP




















Home »
  PHP Tutorial »
    Image »




Color
Create
Font
Operation
Shape
Text