Syntax:bool imagecolordeallocate ($image, $color)
Parameters: this function takes two parameters as above and described below: - $image:is returned by one of the image creation functions such as imagecreatetruecolor(). Used to create the size of the image.
- $color:this parameter contains the color identifier.
Return value:this function returns True on success or False on error.The following programs illustrate the imagecolordeallocate() function in PHP:Program 1:
// Create the size of the image or blank image.
$image_size
= imagecreatetruecolor ( 500, 300);
// Set the background color of the image using
// imagecolorallocate() function.
$bg
= imagecolorallocate (
$image_size
, 0, 103, 0);
// Use the imagecolordeallocate() function for
// free the color
$bg
= imagecolordeallocate (
$image_size
,
$bg
);
// Fill the background with the selected color above.
imagefill (
$image_size
, 0, 0,
$bg
);
// Output image to browser
header (
"Content-type: image / png"
);
imagepng (
$image_size
);
// free memory
imagedestroy (
$image_size
);
?>
Output: Program 2:
// Create the size of the image or blank image.
$image_size
= imagecreatetruecolor (500, 300);
// Set the background color of the image.
$bg
= imagecolorallocate (
$image_size
, 0, 103, 0);
// Use the imagecolordeallocate() function for
// free the color
$bg
= imagecolordeallocate (
$image_size
,
$bg
);
// Fill the background with the selected color above.
imagefill (
$image_size
, 0, 0,
$bg
);
// Set the image colors
$white_color
= imagecolorallocate (
$image_size
, 255, 255, 255);
// Draw a circle
imagearc (
$image_size
, 200, 150, 200, 200, 0, 360,
$white_color
);
// Output image to browser
header (
"Content-type: image / png"
);
imagepng (
$image_size
);
?>
Output: Link: https://www.php.net/manual/en/function.imagecolordeallocate.php