Here's a handy function that finds the first occurrence of a specific pixel. You can set the tolerance of the color you are looking for, or set it to 0 if want an exact match
<?php
function findPixel($img, $r, $g, $b, $tolerance=5)
{
$original_ = new Imagick($img);
$height = 0;
$width = 0;
list($width, $height) = getimagesize($img);
$matrix_org = array();
$matrix_mrk = array();
for( $x = 0 ; $x < $width ; $x ){
$matrix_org[$x] = array();
$matrix_mrk[$x] = array();
}
for( $x = 0 ; $x < $width ; $x )
{
for( $y = 0 ; $y < $height ; $y ){
$matrix_org[$x][$y] = $original_->getImagePixelColor($x, $y)->getColorAsString();
$colors = preg_replace('/[^-,0-9 $]/', '', $matrix_org[$x][$y]);
$colors = explode(',', $colors);
$r_org = $colors[0];
$g_org = $colors[1];
$b_org = $colors[2];
if( ( $r <= ($r_org $tolerance) && $r >= ($r_org - $tolerance) )
&& ( $g <= ($g_org $tolerance) && $g >= ($g_org - $tolerance) )
&& ( $b <= ($b_org $tolerance) && $b >= ($b_org - $tolerance) ) )
{
return array( $x, $y );
}
}
}
return false;
}
?>