PHP | Imagick getImageBackgroundColor() Function
Last Updated :
15 Nov, 2019
The Imagick::getImageBackgroundColor() function is an inbuilt function in PHP which is used to get the image background color.
Syntax:
ImagickPixel Imagick::getImageBackgroundColor( void )
Parameters: This function does not accept any parameters.
Exceptions: This function throws ImagickException on error.
Return Value: This function returns an ImagickPixel set to the background color of the image.
Below programs illustrate the Imagick::getImageBackgroundColor() function in PHP:
Program 1:
<?php
$imagick = new Imagick(
$imagickPixelColor = $imagick ->getImageBackgroundColor();
$color = $imagickPixelColor ->getColorAsString();
echo $color ;
?>
|
Output:
rgb(255, 255, 255) which is the default value.
Program 2:
<?php
$imagick = new Imagick(
$imagick ->setImageBackgroundColor( 'orange' );
$imagickPixelColor = $imagick ->getImageBackgroundColor();
$color = $imagickPixelColor ->getColorAsString();
echo $color ;
?>
|
Output:
rgb(255, 165, 0)
Reference: https://www.php.net/manual/en/imagick.getimagebackgroundcolor.php
Share your thoughts in the comments
Please Login to comment...