# -*- coding: utf-8 -*- |
from PIL import Image |
import os |
# 打开图像得到一个PIL图像对象 |
img = Image. open ( "img1.jpg" ) |
# 将其转为一张灰度图 |
img = img.convert( 'L' ) |
# 存储该张图片 |
try : |
img.save( "test.png" ) |
except IOError: |
print |
"cannot convert" |