Última actividad 9 months ago

PIL(Pillow)是一個強大的 Python 影像處理庫,可用於開啟、編輯、轉換與儲存影像,適用於影像分析、自動化處理與視覺化應用。

timmy revisó este gist 9 months ago. Ir a la revisión

1 file changed, 21 insertions

pillow_example.py(archivo creado)

@@ -0,0 +1,21 @@
1 + from PIL import Image
2 +
3 + # 開啟影像
4 + image = Image.open("example.jpg")
5 +
6 + # 顯示影像
7 + image.show()
8 +
9 + # 轉換為灰階
10 + gray_image = image.convert("L")
11 + gray_image.save("example_gray.jpg")
12 +
13 + # 調整大小
14 + resized_image = image.resize((200, 200))
15 + resized_image.save("example_resized.jpg")
16 +
17 + # 旋轉影像
18 + rotated_image = image.rotate(45)
19 + rotated_image.save("example_rotated.jpg")
20 +
21 + print("影像處理完成!")
Siguiente Anterior