+

PHP Gmagick borderImage () Function

Syntax:
Gmagick Gmagick::borderImage ($bordercolor, $width, $height)
Parameters:This function takes three parameters as above and described below:
  • $bordercolor:This parameter contains a string containing the border color.
  • $width:this parameter is used to set the border width.
  • $height:this parameter is used to set the border height.
Return Value:This function returns a Gmagick object on success.The following programs illustrate the Gmagick::borderImage() function in PHP:Program 1:  
// Create an image object $image = new Gmagick ( ` https://media.engineerforengineer.org/wp-content/uploads/engineerforengineer-9.png ` );  
// Set a border for this image $image -> borderImage ( `green` , 100, 100); header ( " Content-Type: image / jpg " );  
// Show image echo $image ; ?>
Output: Program 2: $string = "Computer Science portal for Geeks!" ;  
// Create a new image of the above line // and add color and background $im = new Gmagick(); $draw = new ImagickDraw();  
// Fill the color in the image $draw -> setFillColor ( new ImagickPixel ( `green` ));  
// Set the text font size $draw -> setFontSize (50); $metrix = $im -> queryFontMetrics ( $draw , $string ); $draw -> annotation (0, 40, $string ); $im -> newImage ( $metrix [ `textWidth` ], $metrix [ `textHeight` ], new ImagickPixel ( `white` ));  
// Draw image $im -> drawImage ( $draw ); $im -> setImageFormat ( `jpeg` );  
// Set a border for this image $image -> borderImage ( `green` , 20, 20); header ( " Content-Type: image / jpg " );  
// Show image echo $image ; ?>
Output: Link: http://php.net/manual/en/gmagick.borderimage.php
Get Solution for free from DataCamp guru