使用 Pillow 庫旋轉影像


在該程式中,我們將使用 Pillow 庫旋轉影像。Image 類中的 rotate() 函式接受旋轉角度。

原圖

演算法

Step1: Import Image class from Pillow.
Step 2: Open the image.
Step 3: Rotate the image.
Step 4: Display the output.

示例程式碼

from PIL import Image

im = Image.open('testimage.jpg')
im.rotate(45).show()

輸出

更新於: 2021 年 3 月 17 日

750 次瀏覽量

開啟你的 職業生涯

完成課程獲取認證

入門
廣告
© . All rights reserved.