PHP 8.3.4 Released!

imagecolorstotal

(PHP 4, PHP 5, PHP 7, PHP 8)

imagecolorstotalFind out the number of colors in an image's palette

Descrizione

imagecolorstotal(GdImage $image): int

Returns the number of colors in an image palette.

Elenco dei parametri

image

Una risorsa immagine, restituita da una delle funzioni di creazione immagine, come imagecreatetruecolor().

Valori restituiti

Returns the number of colors in the specified image's palette or 0 for truecolor images.

Log delle modifiche

Versione Descrizione
8.0.0 image expects a GdImage instance now; previously, a valid gd resource was expected.

Esempi

Example #1 Getting total number of colors in an image using imagecolorstotal()

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

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

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

Il precedente esempio visualizzerà qualcosa simile a:

Total colors in image: 128

Vedere anche:

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top