Every color within an image's palette is assigned an index (0,1, 2, 3, etc.) This indexes are used to identify the hue of the color displayed. Thus, you can change the hue of a particular palette index and change the rendered color quickly:

Adjusting a particular color in the palette is done using imagecolorset()

<?php

    define
("WIDTH"450);
    
define("HEIGHT"450);

    
$img imagecreate(WIDTHHEIGHT);

    
$background $red imagecolorallocate($img0xFF00);
    
imagecolorset($img$background000xFF);
    
header("Content-Type: image/png");
    
imagepng($img);
?>