Skip to content
Related Articles

Related Articles

PHP | Gmagick getimagemattecolor() Function

View Discussion
Improve Article
Save Article
  • Last Updated : 21 Jan, 2020
View Discussion
Improve Article
Save Article

The Gmagick::getimagemattecolor() function is an inbuilt function in PHP which is used to get the image matte color.

Syntax:

GmagickPixel Gmagick::getimagemattecolor( void )

Parameters: This function doesn’t accept any parameters.

Return Value: This function returns a GmagickPixel object containing the color of matte.

Exceptions: This function throws GmagickException on error.

Below given programs illustrate the Gmagick::getimagemattecolor() function in PHP:

Used Image:

Program 1:




<?php
  
// Create a new Gmagick object
$gmagick = new Gmagick('geeksforgeeks.png');
  
// Get the matte color
$colorPixel = $gmagick->getimagemattecolor();
echo $colorPixel->getcolor();
?>


Output:

rgb(48573, 48573, 48573)

Program 2:




<?php
  
// Create a new Gmagick object
$gmagick = new Gmagick('geeksforgeeks.png');
  
// Set the matte color
$gmagick->setimagemattecolor('green');
  
// Get the matte color
$colorPixel = $gmagick->getimagemattecolor();
echo $colorPixel->getcolor();
?>


Output:

rgb(0, 32896, 0)

Reference: https://www.php.net/manual/en/gmagick.getimagemattecolor.php

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!