for ($j = 0; $j < $altura; $j++) {
for ($i = 0; $i < $largura; $i++) {
$rgb = imagecolorat($img, $i, $j);
$rgb = imagecolorsforindex($img, $rgb);
$imagem[$c] = $rgb['red'] + $rgb['green'] + $rgb['blue'];
$e = 9;
$codigo = round(($e * $imagem[$c])/765);
echo $codigo;
$c = $c + 1;
}
echo '<br>';
}
For the time being, what the code does is convert the RGB values by adding them to get a number on a scale of 0 to 9. I want instead of printable numbers, printe pixels of black / gray tones. That is, I want to convert the image to black and white.