Open In App

PHP | Gmagick getimagemattecolor() Function

Improve
Improve
Like Article
Like
Save
Share
Report

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


Last Updated : 21 Jan, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads