<?php
declare(strict_types=1);

$image = imagecreatetruecolor(8, 6);
$white = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $white);
$black = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image, 1, 1, 4, 4, $black);
$red = imagecolorallocate($image, 220, 50, 45);
imagesetpixel($image, 6, 1, $red);
$warnings = [];
set_error_handler(static function (int $severity, string $message) use (&$warnings): bool { $warnings[] = $message; return true; });
try {
    ob_start();
    imagegd2($image);
    $bytes = ob_get_clean();
} finally { restore_error_handler(); }
echo $bytes === "" && $warnings !== [] ? "codec unavailable in this build\n" : "codec available\n";
