(PHP 4, PHP 5, PHP 7, PHP 8)
imagecolorexact — Devuelve el índice del color especificado
Devuelve el índice del color especificado en la paleta de la imagen
image.
If you created the image from a file, only colors used in the image are resolved. Colors present only in the palette are not resolved.
imageUn objeto GdImage, retornado por una de las funciones de creación de imágenes, como imagecreatetruecolor().
redValue of red component.
greenValue of green component.
blueValue of blue component.
Devuelve el índice del color especificado en la paleta, o -1 si el color no existe.
| Versión | Descripción |
|---|---|
| 8.0.0 |
image expects a GdImage
instance now; previously, a valid gd resource was expected.
|
Ejemplo #1 Obtención de los colores que componen el logo GD
<?php
// Define la imagen
$im = imagecreatefrompng('./gdlogo.png');
$colors = Array();
$colors[] = imagecolorexact($im, 255, 0, 0);
$colors[] = imagecolorexact($im, 0, 0, 0);
$colors[] = imagecolorexact($im, 255, 255, 255);
$colors[] = imagecolorexact($im, 100, 255, 52);
print_r($colors);
?>Resultado del ejemplo anterior es similar a :
Array
(
[0] => 16711680
[1] => 0
[2] => 16777215
[3] => 6618932
)