Get the colors for an index in PHP

Description

The following code shows how to get the colors for an index.

Example


<?php//from w  w w  .  j a  va 2 s  .c  o  m

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

// get a color
$start_x = 40;
$start_y = 50;
$color_index = imagecolorat($im, $start_x, $start_y);

// make it human readable
$color_tran = imagecolorsforindex($im, $color_index);

// what is it ?
print_r($color_tran);

?>




















Home »
  PHP Tutorial »
    Image »




Color
Create
Font
Operation
Shape
Text