public static function checkPixel($file, $x, $y, $color = '#FFFFFF', $upper_color = false)
{
if (self::is_png($file)) {
$image = imagecreatefrompng($file);
} else {
if (self::is_gif($file)) {
$image = imagecreatefromgif($file);
} else {
$image = imagecreatefromjpeg($file);
}
}
$pixel_rgb = imagecolorat($image, $x, $y);
$colors_of_file = imagecolorsforindex($image, $pixel_rgb);
if ($upper_color) {
$upper_colors = ImageOperation::hexrgb($upper_color);
}
$test_colors = ImageOperation::hexrgb($color);
if (isset($upper_colors) && $upper_colors) {
if (self::checkChannel('red', $test_colors, $colors_of_file, $upper_colors) && self::checkChannel('green', $test_colors, $colors_of_file, $upper_colors) && self::checkChannel('blue', $test_colors, $colors_of_file, $upper_colors)) {
return true;
}
return false;
}
if ($test_colors['red'] === $colors_of_file['red'] && $test_colors['blue'] === $colors_of_file['blue'] && $test_colors['green'] === $colors_of_file['green']) {
return true;
}
return false;
}