Python_PIL 打开转存图片

来源:互联网 发布:淘宝无线端链接地址 编辑:程序博客网 时间:2024/04/29 13:01

http://www.ituring.com.cn/tupubarticle/2024参考

from PIL import Imageimport 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
0 0
原创粉丝点击