Syntax:ImagickPixel Imagick::getImageBackgroundColor (void)
Parameters:This function takes no parameters.
Exceptions:This function throws an ImagickException on error.
Return value:this function returns the ImagickPixel value set to the background color of the image.The following programs illustrate the
Imagick::getImageBackgroundColor()function in PHP:
Program 1:
// Create a new imagick object
$imagick
=
new
Imagick (
’ https://media.engineerforengineer.org/wp-content/uploads/ engineerforengineer-13.png ’
);
// Get background color
$imagickPixelColor
=
$imagick
-> getImageBackgroundColor();
// Get color from ImagickPixel
$color
=
$imagickPixelColor
-> getColorAsString();
echo
$color
;
?>
Output:rgb (255, 255, 255) which is the default value.
Program 2:
// Create a new imagick object
$imagick
=
new
Imagick (
’ https://media.engineerforengineer.org/wp-content/uploads/engineerforengineer-13.png ’
);
// Set background color
$imagick
-> setImageBackgroundColor (
’orange’
);
// Get background color
$imagickPixelColor
=
$imagick
-> getImageBackgroundColor();
// Get color from ImagickPixel
$color
=
$imagickPixelColor
-> getColorAsString();
echo
$color
;
?>
Output:rgb (255, 165, 0)
Link: https://www.php.net/manual/en/imagick.getimagebackgroundcolor.php