PHP | Gmagick shearimage() Function
Last Updated :
24 Mar, 2021
The Gmagick::shearimage() function is an inbuilt function in PHP which is used to slide one edge of an image along the X or Y axis to create a parallelogram. The X-direction shear slides an edge along the X-axis, while a Y direction shear slides an edge along the Y-axis. The shear angle is used to set shear of the image.
Syntax:
Gmagick Gmagick::shearimage( $color, $xShear, $yShear )
Parameters: This function accepts three parameters as mentioned above and described below:
- $color: This parameter is used to set the background color.
- $xShear: This parameter is used to set degrees to x-shear of the image.
- $yShear: This parameter is used to set degrees to y-shear of the image.
Return Value: This function returns the Gmagick object on success.
Errors/Exceptions: This function throws GmagickException on error.
Below programs illustrates the Gmagick::shearimage() function in PHP:
Program 1:
Input Image:
php
<?php
$gmagick = new Gmagick(
$gmagick ->shearimage( 'blue' , 25, 50);
header( 'Content-type: image/png' );
echo $gmagick ;
?>
|
Output:
Program 2:
php
<?php
$draw = new GmagickDraw();
$strokeColor = new GmagickPixel( 'Red' );
$fillColor = new GmagickPixel( 'Green' );
$draw ->setStrokeOpacity(1);
$draw ->setStrokeColor( 'Red' );
$draw ->setFillColor( 'Green' );
$draw ->setStrokeWidth(7);
$draw ->setFontSize(72);
$draw ->circle(250, 250, 100, 150);
$gmagick = new Gmagick();
$gmagick ->newImage(500, 500, 'White' );
$gmagick ->setImageFormat( "png" );
$gmagick ->drawImage( $draw );
$gmagick ->shearimage( 'yellow' , 20, 40);
header( "Content-Type: image/png" );
echo $gmagick ->getImageBlob();
?>
|
Output:
Reference: http://php.net/manual/en/gmagick.shearimage.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...