Python3 - Pillowの使い方
参考:Python3.3対応画像処理ライブラリ Pillow(PIL) の使い方
from PIL import Imageimport os
file_name = 'img.jpg'
#画像ファイル開くimg = Image.open(file_name)
#グレースケール変換img_gray = img.convert('L')
#リサイズimg_resize = img.resize((100, 100))
#ファイル形式変換file_name_png = os.path.splitext(file_name)[0] + ".png"try: img.save(file_name_png)except: print("cannot convert", file_name_png)
#サムネイル作成file_name_thumbnail = os.path.splitext(file_name)[0] + "_thumb.jpg"img_gray.thumbnail((100, 100))img_gray.save(file_name_thumbnail)