Find out the number of colors in an image's palette in PHP

Description

The following code shows how to find out the number of colors in an image's palette.

Example


 Example #1 Getting total number of colors in an image using imagecolorstotal()
/*  w w  w  . j  a va2 s .  c  o  m*/

<?php
// Create image instance
$im = imagecreatefromgif('php.gif');

echo 'Total colors in image: ' . imagecolorstotal($im);

// Free image
imagedestroy($im);
?>

The code above generates the following result.

Find out the number of colors in an image




















Home »
  PHP Tutorial »
    Image »




Color
Create
Font
Operation
Shape
Text