Skip to content
Related Articles

Related Articles

Improve Article

PHP | Gmagick setimagebordercolor() Function

  • Last Updated : 14 Jan, 2020

The Gmagick::setimagebordercolor() function is an inbuilt function in PHP which is used to set the image border color to be applied.

Syntax:

Gmagick Gmagick::setimagebordercolor( GmagickPixel $color )

Parameters: This function accepts a single parameter $color which holds the color.

Return Value: This function returns a Gmagick object on success.

Exceptions: This function throws GmagickException on error.



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

Used Image:

Program 1:




<?php
  
// Create a new Gmagick object
$gmagick = new Gmagick('geeksforgeeks.png');
  
// Set the border color
$gmagick->setimagebordercolor('#ba5959');
  
// Get the border color
$color = $gmagick->getimagebordercolor();
print("<pre>" . print_r($color->getcolor(), true) . "</pre>");
?>

Output:

rgb(47802, 22873, 22873)

Program 2:




<?php
  
// Create a new Gmagick object
$gmagick = new Gmagick('geeksforgeeks.png');
  
// Set the color of border
$gmagick->setimagebordercolor('red');
  
// Add border
$gmagick->borderimage($gmagick->getimagebordercolor(), 10, 10);
  
// Display the image
header("Content-Type: image/jpg");
echo $gmagick;
?>

Output:

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




My Personal Notes arrow_drop_up
Recommended Articles
Page :