convertメソッドの引数を “L” に設定し、カラー画像をグレイスケールに変換する。
from PIL import Image
img = Image.open('aoi-chan.png')
gray_img = img.convert("L")
gray_img.save('aoi-chan_gray.png')
元の画像
![](https://www.miraiportal.com/wp-content/uploads/2023/07/aoi-chan.png)
変換した画像
![](https://www.miraiportal.com/wp-content/uploads/2023/07/aoi-chan_gray.png)
参考
![](https://raw.githubusercontent.com/python-pillow/pillow-logo/main/pillow-logo-dark-text-1280x640.png)
Image Module
The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a ...