python PIL Image Resize

#!/bin/python
#coding=utf-8
import os
from PIL import Image

dir='/tmp/img/'
fileName=(os.listdir(dir))
size=338,266
for i in fileName:
suffix=i[-3:]
index=fileName.index(i)
im=Image.open(dir+i)
im.convert('RGB').resize(size,Image.ANTIALIAS).save("/tmp/img/"+str(index)+".jpg","JPEG")

posted @ 2013-10-29 16:29  Epirus  阅读(3438)  评论(0编辑  收藏  举报