<?php
$img=imagecreatefrompng('dense.png');
list($width, $height)=getimagesize('dense.png');
$t=0;
for( $i=0 ; $i<$height ; $i++ )
{
for( $j=0 ; $j<$width ; $j++ )
{
$pix = imagecolorat($img, $i, $j);
$cols = imagecolorsforindex($img, $pix);
$r = $cols['red'];
$g = $cols['green'];
$b = $cols['blue'];
$pixel[$i][$j][0]=$r;
$pixel[$i][$j][1]=$g;
$pixel[$i][$j][2]=$b;
}
}
for( $i=0 ; $i<$height ; $i++ )
{
for( $j=0 ; $j<$width ; $j++ )
{
echo "(".$i.",".$j.") color of that pixel is (".$pixelcolor[$i][$j][0].",".$pixelcolor[$i][$j][1].",".$pixelcolor[$i][$j][2].").</p>";
}
echo"<br/>";
}
?>
This is the my code but when i run this code its give me blank webpage.
I want to make one array which store the rgb value of each pixel and it also print on the webpage and reduce those value which are repeating in the array.
so i want to know that how many colors are exist in the images?