<?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);
imagegd2($image, "cache.gd2", 128, IMG_GD2_COMPRESSED);
$loaded = imagecreatefromgd2part("cache.gd2", 1, 1, 3, 2);
echo imagesx($loaded), "x", imagesy($loaded), "\n";
