timmy gist felülvizsgálása 9 months ago. Revízióhoz ugrás
1 file changed, 21 insertions
pillow_example.py(fájl létrehozva)
| @@ -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("影像處理完成!") | |
Újabb
Régebbi