PHP Gmagick shearimage () Function

PHP

Syntax:
Gmagick Gmagick::shearimage ($color, $xShear, $yShear)
Parameters:This function takes three parameters as above and described below:
  • $color:This parameter is used to set the background color.
  • $xShear:this parameter is used to set degrees to the x-shift of the image.
  • $yShear:this parameter is used to set degrees y-shift the image.
Return Value:This function returns a Gmagick object on success.Errors / Exceptions:this function will throw a GmagickException on error.The following programs illustrate the Gmagick::shearimage() functionin PHP:Program 1 :
Input image:  
// Create a Gmagick object $gmagick = new Gmagick ( ` https: / /media.engineerforengineer.org/wp-content/uploads/tech.png ` );  
// shift the image. $gmagick -> shearimage ( `blue` , 25, 50); header ( ` Content-type: image / png` );  
// Ouput image echo $gmagick ; ?>
Output: Program 2: < tbody>  
// Create a GmagickDraw object $draw = new GmagickDraw();  
// Create GmagickPixel $strokeColor = new GmagickPixel ( `Red` ); $fillColor = new GmagickPixel ( `Green` );  
// Set the color, opacity of the image $draw -> setStrokeOpacity (1); $draw -> setStrokeColor ( `Red` ); $draw -> setFillColor ( `Green` );  
// Set the width and height of the image $draw -> setStrokeWidth (7); $draw -> setFontSize (72);  
// Function for drawing a circle $draw -> circle (250, 250, 100, 150); $gmagick = new Gmagick(); $gmagick -> newImage (500, 500, `White` ); $gmagick -> setImageFormat ( "png" ); $gmagick -> drawImage ( $draw );  
// Crop image $gmagick -> shearimage ( `yellow` , 20, 40);  
// Display the output image header ( "Content-Type: image / png" ); echo $gmagick -> getImageBlob(); ?>
Output: Link : http://php.net/manual/en/gmagick.shearimage.php



Get Solution for free from DataCamp guru