//make red circle
imagearc($image, 50, 50, 100, 100, 0, 360, $colorRed);
imagefilltoborder($image, 50, 50, $colorRed, $colorRed);
//make green circle
imagearc($image, 100, 50, 100, 100, 0, 360, $colorGreen);
imagefilltoborder($image, 100, 50, $colorGreen, $colorGreen);
//make blue circle
imagearc($image, 75, 75, 100, 100, 0, 360, $colorBlue);
imagefilltoborder($image, 75, 75, $colorBlue, $colorBlue);
//send image
header("Content-type: image/jpeg");
imagejpeg($image);
?>
integer imagecolorat(integer image, integer x, integer y)
The imagecolorat function returns the index of the color at the specified pixel. All
images have a palette of arbitrary colors referred to by integers.
<?
/*
* Change a color
/
//attempt to open image, suppress error messages
if(!($image = @imagecreatefromjpeg("php_lang.jpg")))
{
//error, so create an error image and exit
$image = imagecreate(200,200);
$colorWhite = imagecolorallocate($image, 255, 255, 255);
$colorBlack = imagecolorallocate($image, 0, 0, 0);
imagefill($image, 0, 0, $colorWhite);
imagestring($image, 4, 10, 10, "Couldn't load image!",
$colorBlack);
header("Content-type: image/jpeg");
imagejpeg($image);
exit();
}
//get the color at (10,10)
$colorIndex = imagecolorat($image, 10, 10);
//change that color to red
imagecolorset($image, $colorIndex, 255, 0, 0);
//send image
header("Content-type: image/jpeg");
imagejpeg($image);
?>