Python中的魔杖旋转()函数
旋转改变图像的方向或将图像旋转到特定角度。 rotate()的度数可以是 0 到 359。(实际上您可以传递 360、361 或更多,但分别与 0、1 或更多相同。)。
Syntax :
Parameters :
Parameter Input Type Description degree numbers.Real a degree to rotate. multiples of 360 affect nothing background wand.color.Color an optional background color. default is transparent. reset_coords bool optional flag. If set, after the rotation, the coordinate frame will be relocated to the upper-left corner of the new image. By default is True.
源图像:
示例 1:
Python3
wand.image.rotate(degree, background, reset_coords)
Python3
# Import Image from wand.image module
from wand.image import Image
with Image(filename ="koala.jpeg") as img:
with img.clone() as rotated:
# rotate image using rotate() function
rotated.rotate(90)
rotated.save(filename ='transform-rotated-90.jpg')
输出 :
示例 2:
Python3
# Import Image from wand.image module
from wand.image import Image
from wand.color import Color
with Image(filename ="koala.jpeg") as img:
with img.clone() as rotated:
# rotate image using rotate() function
rotated.rotate(135, background = Color('rgb(229, 221, 112)'))
rotated.save(filename ='transform-rotated-135.jpg')
输出 :