<?php
$source_file
= "images.jpg";$im
= ImageCreateFromJpeg($source_file);$imgw
= imagesx($im);$imgh
= imagesy($im);$r
= array();$g
= array();$b
= array();$c
= 0;for
($i=0; $i<$imgw; $i++){
for ($j=0; $j<$imgh; $j++){
$rgb = ImageColorAt($im, $i, $j); $r[$i][$j] = ($rgb >> 16) & 0xFF; $g[$i][$j] = ($rgb >> 8) & 0xFF; $b[$i][$j] = $rgb & 0xFF; if ($r[$i][$j] == $g[$i][$j] && $r[$i][$j] == $b[$i][$j]){
$c++;}
}
}
if
($c == ($imgw*$imgh)){
echo "The image is grayscale.";}
else
{
echo "The image is NOT grayscale.";}
?>
After running the program you will get the following output
OUTPUT:The image is NOT grayscale