Pythonでは非常に簡単に画像を扱えます。特に、PythonのPillow(PIL)モジュールを使うと画像をImageクラスのオブジェクトとして扱えて簡単です。
実際に、画像の読込と表示、保存をしてみます。Google Colaboratoryを使用します。
1. モジュール準備
まずは、モジュールを読み込みます。Google Colaboratoryで画像を表示させるので、
import matplotlib.pyplot as plt %matplotlib inline
が必要となります。
from PIL import Image import matplotlib.pyplot as plt %matplotlib inline
2. 読み込み
image_file = "car.jpg" img = Image.open(image_file)
3. 表示
plt.imshow(img) plt.show()

4. 保存
img.save("car2.png")