http://www.ituring.com.cn/tupubarticle/2024参考
from PIL import Image
import os
#pil_im = Image.open('car.jpg')
#pil_im = Image.open('car.jpg').convert('L')
datapath = r'C:\Users\ALI\PycharmProjects\data2sql\PythonForPic\PICS'
filelist = os.listdir(datapath)
for infile in filelist:
outfile = os.path.splitext(infile)[0]+'.jpg'
if infile != outfile:
try:
Image.open(infile).save(outfile)
except IOError:
print "cannont convert",infile