(PHP 4, PHP 5, PHP 7)
imagecolorexact — Get the index of the specified color
$image
, int $red
, int $green
, int $blue
)Returns the index of the specified color in the palette of the image.
이미지를 파일에서 생성하였을 경우, 이미지에서 사용한 색만 해석됩니다. 팔레트에 존재하는 색은 해석되지 않습니다.
imageimagecreatetruecolor() 등의 이미지 생성 함수에서 반환한 이미지 자원.
redRed 컴포넌트 값.
greenGreen 컴포넌트 값.
blueBlue 컴포넌트 값.
Returns the index of the specified color in the palette, or -1 if the color does not exist.
Example #1 Get colors from the GD logo
<?php
// Setup an image
$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);
// Free from memory
imagedestroy($im);
?>
위 예제의 출력 예시:
Array
(
[0] => 16711680
[1] => 0
[2] => 16777215
[3] => 6618932
)