<?php
declare(strict_types=1);

$image = imagecreatetruecolor(3, 2);
$red = imagecolorallocate($image, 255, 0, 0);
imagesetpixel($image, 1, 0, $red);
$count = 0;
for ($y = 0; $y < imagesy($image); $y++) {
    for ($x = 0; $x < imagesx($image); $x++) {
        if (imagecolorat($image, $x, $y) === $red) { $count++; }
    }
}
echo $count, "\n";
