Pillow中怎么旋转图像

   2024-10-13 9110
核心提示:在Pillow中旋转图像可以使用rotate()方法。示例代码:from PIL import Image# 打开图像文件image = Image.open('example.jp

在Pillow中旋转图像可以使用rotate()方法。

示例代码:

from PIL import Image# 打开图像文件image = Image.open('example.jpg')# 旋转图像,顺时针旋转90度rotated_image = image.rotate(90)# 保存旋转后的图像rotated_image.save('rotated_example.jpg')# 显示旋转后的图像rotated_image.show()

在上面的示例中,我们首先打开一个图像文件,然后使用rotate()方法来旋转图像,可以指定旋转的角度。最后保存旋转后的图像并显示出来。

 
举报打赏
 
更多>同类维修大全
推荐图文
推荐维修大全
点击排行

网站首页  |  关于我们  |  联系方式网站留言    |  赣ICP备2021007278号