-2
PHP에서 색상이 있는지 확인하는 방법?그림에 색상이 있는지 알아 보는 방법
function colorIsInPicture('path/to/picture.jpg', '#f55'){ }
PHP에서 색상이 있는지 확인하는 방법?그림에 색상이 있는지 알아 보는 방법
function colorIsInPicture('path/to/picture.jpg', '#f55'){ }
한 가지 방법.
대상 픽셀을 찾고자하는 각 픽셀에 대해 반복합니다.
/**
* Warning: Untested, but *should* work.
* Takes a path to the image file and a color in the form 'rgb(r,g,b)'.
* Left as exercise to reader to test and write any hex support for $sColor.
*/
function colorIsInPicture($sPath, $sColor)
{
$im = new Imagick($sPath);
$it = $im->getPixelIterator();
foreach($it as $row => $pixels)
foreach($pixels as $column => $pixel)
if($pixel->getColorAsString() == $sColor)
return true;
return false;
}
픽셀마다 어떤 색을 가지고 있는지 확인하는 기능으로 모든 픽셀을 반복해야합니다.
imagecolorat() (예 2) 당신이 the PHP Imagick extension를 설치 한 경우 그것을 할 수
http://php.net/manual/en/function.imagecolorallocate.php – brandelizer
지금까지 시도한 적이 있습니까? 이미지 주위에는 많은 PHP 함수가 있습니다 : http://php.net/manual/en/ref.image.php – Fluffeh
그 함수는'locate'가 아니라'allocate'입니다. :) –