(PHP 4, PHP 5, PHP 7)
imagecolorresolve — Get the index of the specified color or its closest possible alternative
$image
, int $red
, int $green
, int $blue
)This function is guaranteed to return a color index for a requested color, either the exact color or the closest possible alternative.
이미지를 파일에서 생성하였을 경우, 이미지에서 사용한 색만 해석됩니다. 팔레트에 존재하는 색은 해석되지 않습니다.
imageimagecreatetruecolor() 등의 이미지 생성 함수에서 반환한 이미지 자원.
redRed 컴포넌트 값.
greenGreen 컴포넌트 값.
blueBlue 컴포넌트 값.
Returns a color index.
Example #1 Using imagecoloresolve() to get colors from an image
<?php
// Load an image
$im = imagecreatefromgif('phplogo.gif');
// Get closest colors from the image
$colors = array();
$colors[] = imagecolorresolve($im, 255, 255, 255);
$colors[] = imagecolorresolve($im, 0, 0, 200);
// Output
print_r($colors);
imagedestroy($im);
?>
위 예제의 출력 예시:
Array
(
[0] => 89
[1] => 85
)