Pgmagick shear() method – Python
Last Updated :
26 May, 2020
The shear() function is an inbuilt function in the Pgmagick library 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:
shear(x, y)
Parameters: This function accepts two parameters as mentioned above and described below:
- x: This parameter is used to set degrees to x-shear of the image.
- y: This parameter is used to set degrees to y-shear of the image.
Return Value: This function returns the Pgmagick object with image added.
Input Image:
from pgmagick import Image, DrawableCircle, DrawableText
from pgmagick import Geometry, Color
img = Image( 'input.png' )
img.shear( 30 , 40 )
img.write( '2_a.png' )
|
Output:
Example 2:
from pgmagick import Image, DrawableCircle, DrawableText
from pgmagick import Geometry, Color
im = Image(Geometry( 600 , 600 ), Color( "# 32CD32" ))
circle = DrawableCircle( 100 , 100 , 300 , 20 )
im.draw(circle)
im.fontPointsize( 40 )
text = DrawableText( 250 , 450 , "GeeksForGeeks" )
im.draw(text)
im.shear( 40 , 50 )
im.write( '1_b.png' )
|
Output:
Share your thoughts in the comments
Please Login to comment...